Archive for December, 2008
JavaFx vs. Flex/Flash
Posted by castever on December 9, 2008
Posted in FLEX, javafx | Tagged: flash, FLEX, javafx, poll | Leave a Comment »
KeyListener in JComboBox
Posted by castever on December 9, 2008
You’ve seen those auto-complete combo boxes out there. SwingX has one, and it is a good one, but not exactly what I needed. I didn’t want all of the highlighting and I didn’t want the options in the combo box to be static. All my suggestions are coming from the database.
So what I discovered and what I want to share is how to listen for key events on an editable jComboBox. If you did something like this:
jComboBox1.addKeyListener(new KeyListener() { ... }
You would not be notified of KeyEvents. Why? you ask. When you type into an editable JComboBox the key events are not being fired on the JComboBox but rather on the editor of that JComboBox.
jComboBox1.getEditor().getEditorComponent().
addKeyListener(new KeyListener() { ... });
Simple as that!
Posted in Java | Tagged: events, Java, tip | 1 Comment »