• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

radiobutton selection

 
amrit sharma
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii...

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 frame.it should happen with either of the radiobuttons.how should i do it.....
please give some suggestions...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
etc

note: a 2nd JFrame is generally a poor choice. JDialog is better suited
 
amrit sharma
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic