jRadioButton

Hi All

I have in my code 3 radio buttons. Now I want to loop between the three of them, and to look which one of them is set on.

Now, they look like jradiobutton1..3, this is how netbeans set them automaticlly. and I want them to be an array.

BTW, How do I change their name ? to be something nicer and readable.

Thanks

Ilan

[362 byte] By [Ilan_Yaniva] at [2007-11-26 17:21:36]
# 1

A good example of why UI-builder generated code sucks, and why writing your own code doesn't.

Like you say, you want them in an array (or a Collection). UI builders are too stupid to know what you want to do in the code - you're smarter than that, so what makes you think the UI builder is a better tool than your fingers? :o)

itchyscratchya at 2007-7-8 23:49:36 > top of Java-index,Desktop,Core GUI APIs...
# 2
You'd probably be better off using an ItemListener to monitor which one is set
duckbilla at 2007-7-8 23:49:36 > top of Java-index,Desktop,Core GUI APIs...
# 3
you create a ButtonGroup, add in it each JRadioButton. Then you can check each radiobutton with the isSelected method
ProZa at 2007-7-8 23:49:36 > top of Java-index,Desktop,Core GUI APIs...
# 4
Er, if they're already in a ButtonGroup, use ButtonGroup.getSelection() to get the model of the relevant button.The model should hold everything you need to access.
es5f2000a at 2007-7-8 23:49:36 > top of Java-index,Desktop,Core GUI APIs...
# 5
Yes, I appear to have missed the wood for the trees, don't I ;o)
itchyscratchya at 2007-7-8 23:49:36 > top of Java-index,Desktop,Core GUI APIs...