File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

check box group

 
Yasir Qureshi
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How should i use checkboxgroup in swing.
Yasir
 
Rene Liebmann
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I forgot that you need a solution for Swing.
Here is the code that you need:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic