I have a group of radio buttons that doesn't includes any text on frame 1.
Every button has a j
label l
, which means that when I choose one radio button, I want to change the icon of a specific j
label.
I want to know which button is selected to send it to frame 2 by a constructor.
So I want send the variable of the current radio button that's clicked.
How can i do that?
public String getSelectedButtonText(ButtonGroup buttonGroup) {
for (
Enumeration<AbstractButton> buttons = buttonGroup.getElements();
buttons.hasMoreElements();
) {
AbstractButton button = buttons.nextElement();
if (button.isSelected()) {
return button.getText();
}
}
return null;
}