Get text from JComboBox

How to get text entered in JComboBox. This text should not be existing.

+6
java jcombobox combobox
source share
2 answers

You can get the selected or entered value from the JComboBox by calling the getSelectedItem method. If this is not an existing element, you will get a String object. Otherwise, you will receive any object in which you filled the combo box.

+14
source share

Just use:

 String value= comboBox.getSelectedItem().toString(); 

Other available examples here.

0
source share

All Articles