aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes KeyListener of JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "KeyListener of JComboBox" Watch "KeyListener of JComboBox" New topic
Author

KeyListener of JComboBox

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
I add a KeyListener to my comboBox. But When I edit an item of my comboBox(Of course, there are key typed, pressed, released events occured), but no event invoked.
If I use the KeyListener in a wrong way why do a keylistener be added to a comboBox.
Thanks in advance.
PS:If I don't describe it clearly, please let me know.


To be or not to be. It's a question.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
in the absence of any code which demonstrates the problem, I will guess

if you are adding your keylistener like this
comboBox.addKeyListener(...

it should be
comboBox.getEditor().getEditorComponent().addKeyListener(...
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
Thank you
It works!
Why don't write this in the java tutorial? Or I've not read it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: KeyListener of JComboBox