This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes multiple listeners on JComboBox Urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "multiple listeners on JComboBox Urgent" Watch "multiple listeners on JComboBox Urgent" New topic
Author

multiple listeners on JComboBox Urgent

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I was wondering if it was possible to add
multiple listeners to a JComboBox eg.
right now I have a ActionListener attached
to the JComboBox, but I want to add a
KeyListener to respond to both the up and
down key is this possible
------------------
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
is this possible yes no? anyone
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

John, I am fairly sure that this is possible. However, I have never done it.
Sorry if that doesn't help much, just wanted to give you a response though.

------------------
Happy Coding,
Gregg Bolinger


GenRocket - A Test Data Generation Platform
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

John, I am fairly sure that this is possible. However, I have never done it.
Sorry if that doesn't help much, just wanted to give you a response though.

------------------
Happy Coding,
Gregg Bolinger
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
I am almost sure that this is not possible. I don't think that you (easily) get information about key stroke since some keys are reserved by the combo box (this is particulary the case for UP and DOWN). We are here more in the field of look-and-feel. Maybe you should have a look to the implementation of ComboBoxUI to see if the key events are consumed or not.
W.
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
is there a way to block them (ie the up or down key)
because when the user presses the up or down key it interacts with the JComboBox and it crashes my programme
 
 
subject: multiple listeners on JComboBox Urgent
 
Similar Threads
JCombobox with multiple columns
Label in Combobox
Onchange JCombobox
how to refresh a JFrame containing a JPanel with lots of Components
Tabbing from a JComboBox inside JTable