This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Combo box with a key listener- pls help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Combo box with a key listener- pls help" Watch "Combo box with a key listener- pls help" New topic

Combo box with a key listener- pls help

Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
HI everbody,
I need a combobox. The combo box will be intially loaded with some items. Now i need a key listener to this combo box, such that when i click ok 's', i need to display the items which begins with 's'. How do i go about this.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
hi Saj,
i've never done that with a combo box only with a list. if its not working with a KeyListener and a uneditable combobox then try to set the JComboBox to setEditable(true). you will have to make sure that the user can use the edit-feature only for the fast lookup.
anyway, try it first with setEditable(false). the combobox must have the focus (mouseclick inside the combo). the keylistener listens to different triggers (KEY_TYPED, KEY_PRESSED). which one is the appropriate depends on the platform and the key. i think, key_typed is the one for you.
I agree. Here's the link:
subject: Combo box with a key listener- pls help
It's not a secret anymore!