Advertisement Jump to content
Sign in to follow this  

[java] Editable JComboBox

This topic is 4915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have an editable JComboBox that I have added an Action and Key listener to to detect changes. My combo box starts off with* two choices of "" and "NULL" as selectable items. My problem is that I need to be able to get the text thats being displayed in the combo box selection window. If it was chosen from the menu of options I could just do getSelectedItem or getSelectedIndex, but if they type something into the box, I cant do that, therefore I cant compare it to "" to see if an appropriate entry was made. Any ideas on how I can get the text in the combo box? I dont want to have to keep track of every key that is type to determine if the box is empty or not. *edit

Share this post

Link to post
Share on other sites

JComboBox cmbBox = new JComboBox();


//Add the key listener to the editor, NOT the combo box itself
//this was the source of half of my troubles

//action listener added to combo box as normal

//getting the text in the box

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!