I want to give a user a convenient way to enter range from swing gui.
What can I use? A perfect option would be a slider with two pointers.
SwingX has JXMultiThumbSlider which is exactly what you're looking for.
Btw, this implementation of RangeSlider is more simple for me, but swingx stuff should work somehow too, if your implement Renderer first.
http://ernienotes.wordpress.com/2010/12/27/creating-a-java-swing-range-slider/
Related
Which is the best way to make a window that has a name a JLabel and two JButton components underneath.
I am new to Swing and I tried some methods but didn't understood too much from any.
What would you suggest to focus my attention on to do this specific thing?
DYM like this?
Or this?
Actually that 2nd one comes from a page linked in the first comment.
But, you might be over complicating the issue and a JOptionPane might be a more suitable solution - see How to make dialogs for more details.
How can I make my own look and feel without inheriting any previous look and feel? I know that it's like "re-inventing the wheel" but I don't actually like any of the existing free look and feels. Any help would be appreciated!
I've done a laf (http://nilogonzalez.es/nimrodlf/index.html) and, well, if you want to write a laf from scratch you have my respect...
The best approach is to extend Metal classes. That way you will get a lot of work done and a bunch of hints of what to do. You will get a lot of components that paint a rectangle and handle events, so to do your laf you "just" have to change the paint* method to paint your laf, but you save an enormous amount of work.
If you want to make your laf without using Metal as basement you will have to do... Well, look at the javadoc to figure the size of your project...
I recomend you to get the Kunststoff sources (http://kunstoff.incors.com/) to take a look of what you have to do. Kunststoff is enough simple to get an idea of what to do, and is very candy even in components that simple have a few lines of code.
This is for an application so I don't want a hyperlink. I first tried using a Jbutton without all of border/background stuff and then hooking up an actionListener to it but I couldn't get it to the point where I thought it looked nice. I also tried using a JLabel and hooking up a mouse listener to that but I also couldn't get it to look right.
Basically I would like a way using swing to make a button exactly like a url link in an application. What is the standard way of doing this?
but I couldn't get it to the point where I thought it looked nice
You might want to go into greater detail on just what "looked nice" means. I can see you solving this by either a JButton or a JLabel, but the key is perhaps not to look for another solution but to play with the settings of the button or the label til they look nice. If you can't find a nice solution, then post your code (an SSCCE would work best of all) and perhaps we can help you.
that isn't answer to your question but are you tried to add ButtonModel to your JButton example here
It is a rather heavy hammer to use, but SwingX has a JXHyperLink control that is probably exactly what you want. The source is at http://java.net/projects/swingx/sources/svn/content/trunk/swingx-core/src/main/java/org/jdesktop/swingx/JXHyperlink.java?rev=4027 and you can see an article about it at http://www.javalobby.org/java/forums/t18617.html.
It is old, but SwingX continues to do good things.
It's you're trying to make a desktop application which looks like HTML inside a browser, you might try using some of the richer Swing text components in a read-only mode. You could use a mouse-listener to map X/Y clicks to a particular character of text, and then cause an action to occur on that basis.
any one know how to change the label side of ChoiceGroup or TextField.( i mean default label come before the TextField. i need to bring label after the TextField)
sorry for my bad English i guess you guys understand the my problem.
there is no direct support in lcdui classes for your requirement, I would suggest try exploring LWUIT
Using standard controls is bad idea at all. Try to use CustomItem, third-party controls or create your own.
I want to get some examples about the GUI of an slot machine written in java, I know that it's kind of specific thing, but i want to know if it's possible to do some animations with java swing, or something like that, greetings
It isn't a slot machine simulation, but you may find related features in this example.
Addendum: The example cited uses Unicode glyphs for variety, but another trick is to implement the Icon interface, which works nicely with some components. This example decorates a JButton for use in a game, while this example extends a child of JLabel to render a table.
This won't answer your question exactly (because I don't have a direct example), but I hope it at least tells you that it's certainly possible.
I've done some games using Java and Swing and such. None of them have been too heavy on the animations. Most of the animations I did happened through the Java 2D Graphics libraries, while more UI stuff happened through Swing.
For example, you can take all of the functionality of a JButton, but override the paintComponent(Graphics g) method to make it look however you want. This was really useful in past projects for me.
The most graphics-intensive Swing-related game I ever built was a "Who Wants to Be a Millionaire?" game. I used animations and graphics and sounds and everything, so I can assure you that it is possible, but it certainly isn't as easy as some other libraries might be.
If you decide to pursue this, I've found that Swing Hacks has some great tips on doing weird things with Swing. Although it isn't focused on gaming, I've found enough interesting things that you can do (Drag and Drop, a bunch of weird things) to make it a worthwhile purchase.