This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes radiobutton selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "radiobutton selection " Watch "radiobutton selection " New topic

radiobutton selection

amrit sharma

Joined: Apr 05, 2010
Posts: 8

i want to select one of the radiobuttons from a radiobutton group and then on clickin the submit button it should take me to a diffrent should happen with either of the should i do it.....
please give some suggestions...
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> please give some suggestions...

assuming the 2 radioButtons have different options on the 2nd frame,
all you do is the same as creating your initial frame:
create frame
add components
show frame

note: a 2nd JFrame is generally a poor choice. JDialog is better suited
amrit sharma

Joined: Apr 05, 2010
Posts: 8
that's fine...but i need to put some conditions on the selection of the radiobuttons.if the user selects a radiobutton and then clicks on submit then it should lead him to a new frame containing different components.similarly if the user chooses different radiobutton and then submit.. it should lead him to a different frame.

can i give some conditions in the actionlistener method of the submit button ragarding the radiobuttons?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
one way would be to have 2 panels option1 and option2
add their respective components to both
add them to the 2nd frame as a CardLayout

now, when submit is clicked, you show the cardLayout panel
as determined by which radioButton is selected
i.e. if rb1 is selected, show option1
if rb2 is selected, show option2
I agree. Here's the link:
subject: radiobutton selection
Similar Threads
Using panelGrid
Relation of Radio Buttons and Combo Boxes in a jsp pge.
getting the formatted values of the session to the jsp page
state of radio button.
form inputs in servlets