Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Leon Hansen   on Jan 13 In Java Category.

  
Question Answered By: Riley-jack Johnson   on Jan 13

If you want to select  one of your JRadioButton you need toadd them in one group.ButtonGroup class will do it for you. Look at the sample:
public class RadioButtonDemo{
JFrame f = new JFrame();
Container c = f.getContentPane();
c.setLayout();
//Instances RaidioButtons
JRadioButton btn1 = new JRadioButon();
JRadioButton btn2 = new JRadioButon();
JRadioButton btn3 = new JRadioButon();

ButtonGroup group = new ButtonGroup();
group.add(btn1);
group.add(btn2);
group.add(btn3);

c. add(btn1);
c. add(btn2);
c. add(btn3);

f.pack();
f.setVisible(true);


}

Share: 

 

This Question has 9 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on GUI problem Or get search suggestion and latest updates.


Tagged: