File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 15299
    
    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 - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple listeners on JComboBox Urgent