After dragging and dropping button group in Netbeans 7.2, how to add radio button in that button group?
Asked
Active
Viewed 4.4k times
11

ollo
- 24,797
- 14
- 106
- 155

Pradip Kharbuja
- 3,442
- 6
- 29
- 50
-
2with code: `btnGroup.add(myRadioBtn)`. What have you tried? – Hovercraft Full Of Eels Dec 12 '12 at 03:22
-
Thank you. I was trying from GUI. Is it possible to be done via GUI? Above code works fine. – Pradip Kharbuja Dec 12 '12 at 03:38
-
1@MouseEvent: I think that he means from NetBeans' Matisse drag and drop code generation tool. Myself, I recommend that he avoid using that tool. – Hovercraft Full Of Eels Dec 12 '12 at 03:43
-
good question clearing basics – Nitesh Verma Apr 09 '13 at 18:11
5 Answers
23
There's a Button Group
field in the radio button's property. Set this value for each of the radio button that you want to add in the group to the button group's name.

Bnrdo
- 5,325
- 3
- 35
- 63
5
- Drag a ButtonGroup from the palette and drop it on your GUI. It will show up under Other Components in the Inspector panel.
- Right-click on it and Change variable name to something meaningful.
- Now select a radio button in your GUI.
- In the Properties panel look for the buttonGroup property.
- Click the combo box next to it and select your button group.
3
Click on the Button Group and then click anywhere in the design form. Select all the buttons you want to group by pressing CTRL and the button. Right click on one of the buttons and select properties. In the ButtonGroup of the Properties, click on the down arrow. Your selection of button groups should appear. Left click on the one you want.

user4992816
- 31
- 1
2
In Netbeans 8.0.1, I use:
ButtonGroup bG = new ButtonGroup();
bG.add(btn_1);
bG.add(btn_2);
bG.add(btn_3);
bG.add(btn_4);
....

user3606336
- 281
- 2
- 4