I appreciate this may be really really simple but I`m having a mental block and hope that someone can help.
I am looking to set up a set of JRadioButtons in a ButtonGroup. Its goigng to look like:
RadioButton one RadionButton two JButton OK
The user should press the OK button and this should capture whatever is selected in the radion buttons.
However I cant think how to do this, I assume I attach an actionlistener to each Button but surely this would just mean when they click on the OK the window would close and the selection would not be captured as the event would only register the OKButton.
See if this helps: Java Swing Tutorial: How to use buttons, etc..
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Jan 27, 2006
I have checked that site, I`ve had quite a long look but all that shows is what happens when you click the button. However it does not show what happens if an ok button is added into that.
I`ll try to explain it a bit better. I`m going to set up a class that has universal JRadioButtons yes and no. It also has a universal intger ReturnChoice which returns 1 for yes and 0 for no. If I add an actionlistener to all the buttons will the actionPerformed method be able to change from 1 to 0 depending on which option the user chooses? If the user then clicks on OK when the window closes will this choice be remembered so I can call it using a method like getChoice() which would return an integer value?
I really am only scratching the surface of swing so any helps or good book tips are much appreciated [ February 25, 2006: Message edited by: Derrick Ritchie ]