Results 1 to 11 of 11
  1. #1
    nando88 is offline Member
    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0

    Default Change JProgressBar Text Color

    I want to change the text color of the progress bar to black, but I don't know how.
    Everything I have tried hasn't worked.
    Can someone please tell me how to change the text color of the progress bar?
    Thanks in advance!

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Change JProgressBar Text Color

    Are we supposed to guess what you have tried?

    Have you looked at the API to see what methods are available. Don't forget to look at inherited methods as well

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Change JProgressBar Text Color

    You also need to tell us what progress bar this is about. Java doesn't have a single, unique progress bar and we're not about to start guessing.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    nando88 is offline Member
    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0

    Default Re: Change JProgressBar Text Color

    Quote Originally Posted by DarrylBurke View Post
    You also need to tell us what progress bar this is about. Java doesn't have a single, unique progress bar and we're not about to start guessing.

    db
    The progress bar I'm using is the one from the swing controls.
    The code that I'm currently using is:
    Java Code:
    initComponents();   
    UIManager.put("jb.selectionForeground", new ColorUIResource(Color.BLACK));
    UIManager.put("jb.selectionBackground", new ColorUIResource(Color.BLACK));

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Change JProgressBar Text Color

    So I google

    "java swing progressbar background color"

    and first hit:

    change progressBar look and feel (Swing / AWT / SWT forum at JavaRanch)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    nando88 is offline Member
    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0

    Default Re: Change JProgressBar Text Color

    I already tried that, and it didn't work.
    The look and feel I'm currently using is Metal.
    I can change the color of the progress bar, but not the text color of the text that is painted in it.
    Thanks in advance!

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Change JProgressBar Text Color

    Read through the source of the UI delegate (probably javax.swing.plaf.metal.MetalProgressBarUI) and find how the colors are determined. Once you know that it will be trivial to change it.

    Also, any changes to UIManager properties should be done before, not after, the Components are constructed.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Change JProgressBar Text Color

    Moved from New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    nando88 is offline Member
    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0

    Default Re: Change JProgressBar Text Color

    I Already Fixed it, I used the information in this tutorial:
    https://www.google.hn/?gws_rd=cr&ei=...+java&start=30
    Thank you all for your help!

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Change JProgressBar Text Color

    That's a Google search and not a tutorial, but I'm glad that you did one and fixed your issue.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    nando88 is offline Member
    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0

    Default Re: Change JProgressBar Text Color

    I used the foreground method, but I also changed the look and feel of the application, because without that, the text color will not change.

Similar Threads

  1. Replies: 0
    Last Post: 02-09-2012, 05:01 PM
  2. Applet to change text color
    By sak_java in forum Java Applets
    Replies: 8
    Last Post: 02-19-2011, 07:56 PM
  3. Change text color on type
    By corbokhan in forum New To Java
    Replies: 2
    Last Post: 11-01-2010, 08:30 PM
  4. change syntax text color
    By dejos456 in forum New To Java
    Replies: 5
    Last Post: 12-14-2009, 12:09 PM
  5. Replies: 0
    Last Post: 06-25-2008, 11:33 AM

Posting Permissions

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