I have a group of radio buttons defined as 'ButtonGroup bg1;
' using 'javax.swing.ButtonGroup
' package. I would like to disable this group so that the user cannot change their selection after clicking the OK-button 'btnOK
'.
So I was looking for something along these lines:
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {
bg1.setEnabled(false);
}
However, .setEnabled(false)
does not seem to exist.
getElements
that returns an enumeration of buttons in the group. Iterate over that and callsetEnabled(false)
on each button. – Laevorotation