Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JList Selection  RSS feed

 
rajesh kumar jhaver
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added ListSelectionListener to the JList and have overidden the method valueChanged., when I change the value present in the list with the arrow keys the event is fired once but with mouse selection the event is fired twice.
thanks in advance
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to look at the return value of ListSelectionEvent.getValueIsAdjusting(). If you're going to get more than one event, all but the last of them will return "true"; the last one will return "false". It returns false for single events, too. Have your event handler only respond to "false" events.

[ August 11, 2003: Message edited by: Ernest Friedman-Hill ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!