This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionListener on JComboBox

 
Herbert Kornfeld
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic