Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying certain items on a panel based on radio button selection.  RSS feed

 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have to design a GUI where in user should enter information like name, ID number, university, company etc. I have to provide radio button selection to choose between two sets of information. For example, let radioButton1(student) be the default where in the panel should display name, ID number and University. If radioButton2(employee) is selected, the panel should now display name, ID number and company(i.e should not display University field).

It would have been easier if I could just disable the unwanted components based on selection but am not sure how to display only selected items. I have pasted my code which renders the panel properly initially and disables the unwanted items. Please tell me how I could change the code to display only selcted items.

Thanks in advance!
Thejaswini.


[ September 25, 2007: Message edited by: thejaswini ramesh ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is just changing the label text an option?
 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael!

But just changing the label may not help because I may have to add more items for employee(not necessarily JTextField, maybe JComboBoxes) which are not common to student category. Any other way I can do this?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds like your best option is 2 panels in a cardlayout panel.
the radioButton selection determines which panel (Student or Employee) is shown
 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael!!
It is working with CardLayout panel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!