-
I have a combo box that looks like this:
Code:
//Combo Box
JComboBox cboTestNum = new JComboBox();
cboTestNum.addItem("1");
cboTestNum.addItem("2");
cboTestNum.addItem("3");
cboTestNum.addItem("4");
cboTestNum.setSelectedIndex(0);
I put it on my panel and now I want to find out what item is selected and assign it to an integer variable...
All I get is Null Pointer problems...
How can I assign the selected item to a variable named test?
Code:
int test;
test = Integer.parseInt("" + cboTestNum.getSelectedItem());
is giving me errors...
Thanks!
-
Is there a getSelectedItem() method? I know the selectedItem property represents the object currently select in the combo box. But looking through my books i dont see a getSelectedItem method......
Where are the NullPointer Exception being generated?