Hello,
I need some guidance as to how I can determine which RadioButton or RadioButtons was/were selected if some are grouped together on several tabbed panes?
I have already created my tabbed pane GUI, in which my class implements ActionListener, and my (empty) actionPerformed function is provided.
However, what do I put in this function to check each RadioButton? Do I use a for loop as in the example below? This is not easy for me to understand. Any assistence will be appreciated. Thanks in advance.
Code:// This method returns the selected radio button in a button group public static JRadioButton getSelection(ButtonGroup group) { for (Enumeration e=group.getElements(); e.hasMoreElements(); ) { JRadioButton b = (JRadioButton)e.nextElement(); if (b.getModel() == group.getSelection()) { return b; } } return null; }




Reply With Quote