So I have a JComboBox and a button. I want the user to select an option from the combo box, then click the delete button which will call the action listener:
ActionListener DeleteVert = new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); String Selection = (String)cb.getSelectedItem(); System.out.println(Selection); } }; Delete.addActionListener(DeleteVert);
When I try to click the button it throws an exception on the line:
JComboBox cb = (JComboBox) e.getSource();
The exception says something about an unknown source. Anyone got any ideas whats wrong?