Java JProgressBar color

Discussion in 'Mac Programming' started by NewbieNerd, Sep 6, 2006.

  1. macrumors 6502a

    NewbieNerd

    Joined:
    Sep 22, 2005
    Location:
    Chicago, IL
    #1
    Anyone know how to change the color of the JProgressBar?
     
  2. macrumors 68000

    Josh

    Joined:
    Mar 4, 2004
    Location:
    State College, PA
    #2
    Before creating the progress bar, add these lines:
    Code:
    UIManager.put("ProgressBar.selectionBackground",Color.BLUE);
    UIManager.put("ProgressBar.selectionForeground",Color.WHITE);
    
    Change the colors as needed.

    (got this from a google search)
     
  3. thread starter macrumors 6502a

    NewbieNerd

    Joined:
    Sep 22, 2005
    Location:
    Chicago, IL
    #3
    Yeah, I found that, but it doesn't seem to work for me.
     
  4. thread starter macrumors 6502a

    NewbieNerd

    Joined:
    Sep 22, 2005
    Location:
    Chicago, IL
    #4
    Okay, so it can be done if you use a different LookAndFeel ( I tried the Metal one ) instead of the default Aqua, but (a) I don't really want to change from Aqua, and (b) that doesn't allow me to change after creating stuff.
     
  5. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #5
    Aqua is Aqua, you can't change it except for blue and graphite.

    You could probably find a look-and-feel that's similar that can be modified and that one might take fewer resources to run.
     
  6. thread starter macrumors 6502a

    NewbieNerd

    Joined:
    Sep 22, 2005
    Location:
    Chicago, IL
    #6
    Yeah, makes perfect sense. I had figured the same since I first started trying to figure out how, but my boss thought it would look nice to turn the bar green/yellow/red, and I have very little GUI experience so I couldn't argue.

    So obviously part of this is showing the status of something, best represented by the traditional stop light colors. Anyone have a creative way to do it? I'm trying to figure the Graphics2D stuff out to do it that boring way, but I'm interested if anyone has any brighter ideas.
     

Share This Page