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.
Related
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);
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).
Going to make a pretty statistic part for my app and saw a pretty good looking UI (see below). What I'm asking is what's the approach? I have a few ideas, for example drawing multiple ImageButtons (one for every text field) and paint the background the same color as the ImageButtons.
This if i want each of the texts to be clickable, in the example picture for example pressing 18c fires one action and pressing Cambridge another action.
How would you approach this?
What components to use?
Want to do as much as possible in xml, but I'll take suggestions in code too. Whatever is better for you.
EDIT:
Found a good example about how to solve the listView part:
http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
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.
i have a desktop GUI in swing , i want to show status of user storage used in the GUI, currently i am using JProgressBar, which is not much attractive, It seems like a simple progress bar.
Please suggest some attractive way to do.
If you are looking for more attractive design. I could suggest you a couple of things:
1-Have a look at javaFX progress bars , you might find something interesting
http://download.oracle.com/javafx/1.3/tutorials/UIControls/progress.html
2-If you use the standar progress bar from the java tutorial maybe you could try to edit it yourself. Have a look at this link
Example of self customization:
UIManager.put("ProgressBar.background",Color.BLUE);