• 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

check box group

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How should i use checkboxgroup in swing.
Yasir
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
If you are looking to the API, then you will find following little sample code:

As for a short description, imagine you have a bundle of Checkboxes, which belong together, like on and off or some colors. Anyway, there can be only one selection and not several. If you don't want to take RadioButtons with a ButtonGroup, then you can take Checkboxes with a CheckBoxGroup. This group manages, that there can be only one selection in its members.
 
Yasir Qureshi
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot but gave solution in awt.
I have written following code, but its allowing multiple checkbox to be selected.
ButtonGroup bg=new ButtonGroup();
JButton b1=new JButton("b1");
JButton b2=new JButton("b2");
JButton b3=new JButton("b3");
bg.add(b1);bg.add(b2);bg.add(b3);
How could i allow single box to be selected.
i.e equivalent of button.setCheckboxGroup() in swing.
Yasir
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I forgot that you need a solution for Swing.
Here is the code that you need:
 
reply
    Bookmark Topic Watch Topic
  • New Topic