*
The moose likes Swing / AWT / SWT and the fly likes ActionListener on JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ActionListener on JComboBox" Watch "ActionListener on JComboBox" New topic
Author

ActionListener on JComboBox

Herbert Kornfeld
Ranch Hand

Joined: Apr 16, 2003
Posts: 32
Hi,
I have an actionListener registered against a JComboBox and it is acting like an ItemListener in that if I programtically change the selection of the combobox it fires the action - but that is not the behaviour I want - I only want the action to fire if the user manually manipulates the combo box (with the mouse).

Thanks
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1131

Herbert,
Pardon me for stating the obvious, but if you

only want the action to fire if the user manually manipulates the combo box (with the mouse)

then wouldn't a "MouseListener" be more appropriate?
http://java.sun.com/j2se/1.4.1/docs/api/java/awt/event/MouseListener.html
[You can use the "addMouseListener()" method that "JComboBox" inherits from class "java.awt.Component".]
Hope this helps.
Good Luck,
Avi.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ActionListener on JComboBox