简体   繁体   中英

Java Progress Bar is Grey

I implemented an indeterminate java progress bar in my program but for some reason the progress bar is grey instead of blue. Any ideas why this is happening?

灰色ProgressBar

This is how the progress bar looks; it is supposed to have moving blue lines shown below instead of the stationary grey ones as shown in the picture.

在此处输入图片说明

Maybe the JProgressBar is disabled. When working with a GUI Editor, search for the option enabled and make sure it is set to true .

You can do it manually as well by calling:

progressbar.setEnabled(true);

I will assume that you are talking about a awt/swing application. The progress bar color, along with every other GUI element, is regulated by the Look & Feel of the application. Swing/awt have standardized look and feels, but also some that are heavily platform-dependent. For more precise information, please provide a screenshot of your progress bar and also of the one that you think your bar should look like.

For information how to set the look & feel, look here: http://docs.oracle.com/cd/E17409_01/javase/tutorial/uiswing/lookandfeel/plaf.html

EDIT: Can you provide the code of your app where you define the progress bar? I assume it is a JProgressBar? Also, what OS do you use?

EDIT EDIT: The progress bar you created can have its look and feel changed.

http://www.java2s.com/Tutorial/Java/0240__Swing/CustomizingJProgressBarLookandFeel.htm

Experiment with the mentioned properties like that:

UIManager.put("ProgressBar.selectionBackground", Color.blue);

Until you achieve a result that is suitable to you. Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM