I made a panel for my program. It consists of RadioButtons only. When a radiobutton is selected, I want to set a boolean in other code. This panel will be used as a component of a bigger panel or frame which should also be able to listen to the events happening inside this panel.
So, which of the following options should I choose for listening to events -
1 -
RadioButtonPanel extends JPanel implements ActionListener{
public void actionPerformed(ActionEvent e){}
//code to add the action listener to the radio buttons
oneRadioButton.addActionListener(this);
}
2 -
RadioButtonPanel extends JPanel{
class InnerStrength implements ActionListener{
public void actionPerformed(ActionEvent e){}
}
//code to add the action listener to the radio buttons
oneRadioButton.addActionListener(Anonymous InnerStrength)
}
3 - Any other way to do it that I did not think of ?