How to retrieve Text that is typed in JComboBox. This text need not be an existing item.
You can get the selected or typed value from a JComboBox by calling method getSelectedItem
. If it is not an existing item, then you'll get a String object. Otherwise you'll get whatever object you populated the combo box with.
Simply use :
String value= comboBox.getSelectedItem().toString();
Other examples available here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With