简体   繁体   中英

How to check condition that 'only one jRadiobutton should be selected'

I am working on details entry form on NetBeans with Java Swings. There are three certain jRadiobutton, of them only one must be selected . Any methods that could give such power, please suggest. Or might I need to custom my own method to perform check?

You have to create a object of ButtonGroup and add radio buttons to that object.

JRadioButton birdButton = new JRadioButton(birdString);
birdButton.setSelected(true);

JRadioButton catButton = new JRadioButton(catString);

   //Group the radio buttons.
ButtonGroup group = new ButtonGroup();
group.add(birdButton);
group.add(catButton);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM