Win a copy of Head First Agile this week in the Agile 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: 24217
38
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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!