• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionListener on JComboBox

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic