Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

On the JComboBox - ItemListener becomes the events tow times

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Geza Kovacs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's logic thanks.There was also a small bug in my code, the listener was added two(oops) times.
Thanks !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic