Good day
Would like to know how to add radiobuttons to a ButtonGroup by dragging and dropping components on to the frame.
JRadioButton male = new JRadioButton("Male");
JRadioButton female = new JRadioButton("Female");
ButtonGroup bg = new ButtonGroup();
bg.add(male);
bg.add(female);
pane.add(male);
pane.add(female);
How can I do this by simple dragging and dropping. If I drop the ButtonGroup onto the frame it gets grouped under 'other components' and from there I am not exactly sure how to add radio buttons to the button group.
thanks regards Arian
you have look at HierarchyListener, on hierarchyChanged
event you have add a new JRadioButton
to the ButtonGroup
, carefully with last know isSelected for concrete JRadioButton