Java Progress Bar is Grey - java

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?
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.

Related

Make GUI not react on user input

i built a GUI which also can save something and what I want is that during that saving, no user input is possible and buttons etc cannot be clicked or at least do not react on that.
Maybe you can give me an hint, how to that!
Thanks!
On way might be to use a progress bar. Maybe an indeterminate progress bar that displays animation while waiting for the task to finish.
Check out the section from the Swing tutorial on How to Use Progress Bars for more information and working examples.
Another option could be to use the Disable Glass Pane which will prevent the mouse an keyboard from working.
If you want to avoid user actions, you can disable every objects :
myButton.setEnabled(false);

Increase size of title bar in Swing

I am trying my hand in swing applications and would like to know if there is a way to increase the height of the title bar of a JFrame/JDialog?
And also Can I get rid of the Swing icon and replace it with an icon of my own choice?
Sorry if this is a repeated question/too silly , I just haven't found a suitable answer anywhere yet :( Thanks !
.. if there is a way to increase the height of the title bar of a JFrame/JDialog?
Given that wold make that one app. inconsistent with all the other apps. that open on this machine, I'd sure hope not. (And as far as I know, 'no it is not possible'.)
Can I get rid of the Swing icon and replace it with an icon of my own choice?
See JFrame.setIconImage(Image).

Progress Bar used as Health Bar

I am making a java game that has a sidebar that displays a player's health. I want the bar to be like a progress bar which is along the lines of the picture below:
Would a progress bar be capable enough to accomplish this? If not, what will?
If you want an "official" answer, then yes, a JProgressBar can do this easily. I suggest that you give it a try and let us know how it works out, especially if you have any problems with it.

Is it possible to remove the little dropdown arrow in a JInternalFrame?

I'm using a JInternalFrame and I want to remove the dropdown in the upper left of the frame, as it serves no purpose (I've disabled resizeable, closable, etc.)
I don't see a property for this, and I don't want to remove the entire title bar, as the title is necessary. I've looked around online, and basically come up empty here. I'm hoping it's something simple that I've just overlooked, as this is my first time using JInternalFrame, and I'm not exactly a GUI kind of guy to begin with.
internalframe.setFrameIcon(null);
Edit: hack to remove system menu in Windows:
BasicInternalFrameUI ui = (BasicInternalFrameUI)internalFrame.getUI();
Container north = (Container)ui.getNorthPane();
north.remove(0);
north.validate();
north.repaint();
The relevant Icon in The Synth Look and Feel, among the Nimbus Defaults, appears to have this key:
InternalFrame:InternalFrameTitlePane:"InternalFrameTitlePane.menuButton".icon
You may be able to use the approach shown in A Synth Example to replace the Icon.
setFrameIcon(anyBigImageThatCantBeDisplayed);
I´ve tried null parameter and got some visual issues...
So i added a big image(no background) that was already on my resource folder and the icon was no longer displayed as the menu...

Remove some layout elements from JProgressBar

I would like to know if it's possible to remove red areas(on JProgressBar) on the following image.
These are blue lines on the top and left side of the progress bar which I would like to remove. I have managed to remove it with paint() method, painting progress bar manually. But probably there is more correct way of doing it.
Thanks,
Serhiy.
Not tested but i think progressBar.setBorderPainted(false) should do the trick.
Subclassing JProgressBarand overriding paint()is fine and perfectly correct if you want to modify the bar's behaviour. I'm not sure where your blue lines are coming from though; do you have a shadow effect set somewhere?

Categories