简体   繁体   English

Java进度栏为灰色

[英]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. 我在程序中实现了一个不确定的Java进度条,但是由于某种原因,进度条是灰色而不是蓝色。 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. 也许JProgressBar被禁用了。 When working with a GUI Editor, search for the option enabled and make sure it is set to true . 使用GUI编辑器时,搜索enabled的选项并确保将其设置为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. 我假设您正在谈论awt / swing应用程序。 The progress bar color, along with every other GUI element, is regulated by the Look & Feel of the application. 进度条的颜色以及其他所有GUI元素均由应用程序的外观进行控制。 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 有关如何设置外观的信息,请参见此处: 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? 我认为这是一个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 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. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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