-
Bug
-
Resolution: Fixed
-
P3
-
1.0.2, 1.1.5, 1.2.0
-
None
-
1.2fcs
-
generic, unknown, x86
-
generic, solaris_2.5.1, windows_nt
-
Not verified
Create a JList with some items in it and add a ListSelectionListener to it. Click on one of the items - notice that your ListSelectionListener is called, multiple times, with the last call having firstIndex==lastIndex, and isAdjusting==false. Now use the arrow keys to arrow up and down in the List, selecting new items. Notice that your ListSelectionListener is called only once for each arrow keypress, and firstIndex!=lastIndex (though isAdjusting==false). firstIndex differs by 1 from lastIndex. This incorrectly implies that the selection contains two list items, right next to eachother, when in fact it doesn't. It only contains one item, whose index is lastIndex.
====================
Here's some code that demonstrates the issue:
tom.santos@eng 1998-05-28
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import java.awt.event.*;
public class ListTest {
public static void main( String[] argv ) {
JFrame frame = new JFrame( "List Test" );
frame.addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e ){
System.exit( 0 );}});
JList list = new JList( new Object[] { "Orion", "Coma Berenices", "Lyra", "Leo", "Triangulum" } );
list.addListSelectionListener( new ListSelectionListener() {
public void valueChanged( ListSelectionEvent e ) {
System.out.println( e );
}
});
frame.getContentPane().add( list );
frame.pack();
frame.show();
}
}
====================
Here's some code that demonstrates the issue:
tom.santos@eng 1998-05-28
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import java.awt.event.*;
public class ListTest {
public static void main( String[] argv ) {
JFrame frame = new JFrame( "List Test" );
frame.addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e ){
System.exit( 0 );}});
JList list = new JList( new Object[] { "Orion", "Coma Berenices", "Lyra", "Leo", "Triangulum" } );
list.addListSelectionListener( new ListSelectionListener() {
public void valueChanged( ListSelectionEvent e ) {
System.out.println( e );
}
});
frame.getContentPane().add( list );
frame.pack();
frame.show();
}
}
- duplicates
-
JDK-4129305 JList ListSelectionEvent more than once
-
- Closed
-