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

What listeners can be added to JList?  RSS feed

 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, what are the listeners that can be added to a JList?Actually I want to set the text ina TextField as the value of the selected Item in the JList,but this should be set only when the selected item is clicked.I used ListSelectionListener,but the valuechanged() method is called twice.What is the problem?Please reply this elobarately,for I wish to know about event listeners.
Happy middling with java.
Netharam. :roll:
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ListSelectionListener's valueChanged() method gets called twice... once for the old value being de-selected, and once for the new value being selected. The easiest way to see if it's the "new selection" event is to test the getValueIsAdjusting() method of the ListSelectionEvent in your valueChanged() method.

-Nate
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!