aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes On the JComboBox - ItemListener becomes the events tow times Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "On the JComboBox - ItemListener becomes the events tow times" Watch "On the JComboBox - ItemListener becomes the events tow times" New topic
Author

On the JComboBox - ItemListener becomes the events tow times

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hallo
I have a JComboBox and I listen it with a ItemListener implementation.What is wonder me is that the events are coming two times(every time for each state select or deselect).Why two times ?


SCJP, SCJD, SCWCD, OCPJBCD
Geza Kovacs
Greenhorn

Joined: Nov 10, 2004
Posts: 4
Originally posted by Mihai Radulescu:
Why two times ?


You will receive one or two ItemEvents when the selection changes. The first event is "item deselected" (the old selection). If the original selection is empty, you won't receive this event. The second event is "item selected" (only if the new selection isn't empty).
[ November 10, 2004: Message edited by: Geza ba ]
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

That's logic thanks.There was also a small bug in my code, the listener was added two(oops) times.
Thanks !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: On the JComboBox - ItemListener becomes the events tow times
 
Similar Threads
knowing when JComboBox's data has changed
Swing Program gets freezed
Jcombobox
ComboBox ItemListener calling twice..
weird thing happening with JComboBox