I didnt group my jradiobuttons so that users can select multiple choices and i can store in the nodes array..but it only reads once. What is wrong with the code? Please enlighten me
private String[] showGUIForNodeDeletion() {
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(map.size(), 1));
ButtonGroup btnGrp = new ButtonGroup();
final String nodes[] = new String[10];
Set<String> keySet = map.keySet();
for (String name : keySet) {
btnRadio = new JRadioButton(name);
btnRadio.setActionCommand(map.get(name).x + "," + map.get(name).y + "," + name);
//btnGrp.add(btnRadio);
panel.add(btnRadio);
}
btnRadio.addActionListener(new ActionListener() {
int x = 0;
public void actionPerformed(ActionEvent e) {
nodes[x] = ((JRadioButton) e.getSource()).getActionCommand();
System.out.println("Node counting " + x);
x++;
}
});
if (keySet.isEmpty()) {
JOptionPane.showMessageDialog(AnotherGuiSample.this, "Work Space is empty", "Error", JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(AnotherGuiSample.this, panel, "Select node to remove", JOptionPane.INFORMATION_MESSAGE);
}
for(int x = 0; x < nodes.length; x++ )
System.out.println("node is " + nodes[x]);
return nodes;
}