Sonntag, 28. Januar 2007

SelectionListener is called twice on a JList

Problem:
"I am using a Jlist. To control the selected Item I am using a SelectionListener. But the method
valueChanged(ListSelectionEvent) is allways called twice when I select an Item from the List."

Solution:
There are two events fired. One for a select and one for a deselect. Use this code to execute only if the Item is selected:
ListSelectionEvent e;
if(! e.getValueIsAdjusting())







Keine Kommentare: