void (JRadioButton[] buttons, ChangeListener changelistener) { ButtonGroup buttongroup = new ButtonGroup(); for (JRadioButton button : buttons) { button.getModel().addChangeListener(changelistener); buttongroup.add(button); } if (buttongroup.getSelection() == null) buttongroup.setSelected(buttons[0].getModel(), true); }