• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael!!
It is working with CardLayout panel.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic