Name: krT82822 Date: 03/18/2000
/*
1.3.0rc2-W
(see also 4298197 -- and 4134544 <<<--- )
orig. synopsis: "Clicking on a line in a JList with the mouse gives double events"
Selecting a line in a JList using the mouse gives duplicate events, whereas
moving the cursor with the arrow keys give single events.
In the following, clicking with the mouse on a line (say 'two') results in two
identical lines being printed.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class JListBug102390 extends JFrame {
public JListBug102390() {
super( "Double selection bug" );
Container c = getContentPane();
String[] items = { "one", "two", "three", "four", "five" };
final JList list = new JList(items);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
c.add(list);
list.addListSelectionListener(
new ListSelectionListener() {
public void valueChanged (ListSelectionEvent e) {
System.out.println(list.getSelectedValue());
}
}
);
pack();
}
public static void main(String[] args) {
JListBug102390 f = new JListBug102390();
f.setLocation(300,300);
f.setVisible(true);
}
}
(Review ID: 102390)
======================================================================