0

I've problem with a JComboBox SelectedItem can someone help me ? I've implemented a GUI window where are a various textfield and one JComboBox. When I click button, code must create an Object with the strings of the textfield and string of ComboBox, but I've a NullPointerExceptionin SelectedItem... The code to get is :

(String)combo.getSelectedItem()

I tried too:

combo.getSelectedItem().toString()

but don't work ! I don't know if I need a ActionListener but think it's not required.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
BitProgram
  • 59
  • 10

1 Answers1

0

you can get the jcombox selected items like this.

String item = jcombox.getSelectedItem().toString ();

I Placed this code on onclick event of a button and it worked.

Habib Mhamadi
  • 729
  • 1
  • 6
  • 15