CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    23

    Changing applet color and Filling Jslider

    Hi to all,
    Hope all will be fine. Actually i want to ask that how can i change the applet color. By google i found that use

    Code:
    setBackground(Color.Blue) // or whatever color you want
    In the init() method but its not working. I also put this is paint() method but still no result . Actually i gave my recorder applet the window look and feel by putting the code

    Code:
       static {
                try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                }catch (Exception ex) {
                   ex.printStackTrace();
                }
        }
    When you see the attachment the applet is of gray color and on another computer is of windows like yellow color. If i want to change the color how can i do it please guide me.

    Also in the recorder you see when slider moves the space it's left from its left is empty i want to fill it with some color. I used the code

    Code:
     progressSlider = new JSlider(SwingConstants.HORIZONTAL, 0, TOTAL_MINS * 60, 0);
     progressSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
    but it is not working also, so please tell me how can i fill the slider with some color from it's left when it is moving.

    Thanks in advance
    Attached Images Attached Images

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Changing applet color and Filling Jslider

    If you want to change the way the slider is painted, you'll need to subclass it and override the paintComponent() method. The first call in the override should be to the superclass method, so normal painting is done, then you can fill the track rectangle from the start position to the current slider position by setting the graphics colour and calling the graphics fillRect method.

    I hear and I forget; I see and I remember; I do and I understand...
    Confucius
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Aug 2009
    Posts
    23

    Re: Changing applet color and Filling Jslider

    Hi ,
    Hope you are at good health.Thanks for your reply.I did change the color of the applet by putting the code

    Code:
      static {
                try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                }catch (Exception ex) {
                   ex.printStackTrace();
                }
    
                UIManager.put("Panel.background", new Color(221, 221, 231));
    
        }
    but this will not change the color of slider then i change the color of slider by
    Code:
    progressSlider.setBackground(new Color(221, 221, 231));
    Now the whole applet is in same color

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured