Name: iaR10016 Date: 09/06/2000
JDK version:
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-b17)
Java HotSpot(TM) Client VM (build 1.3.0rc1-b17, mixed mode)
Java 2 Platform SE v1.3 specification reads about List item selecting:
...
Clicking on an item that isn't selected selects it.
Clicking on an item that is already selected deselects it.
...
In Linux JDK 1.3 and Solaris JDK 1.3 clicking on selected List item does not
deselect it.
The following test example creates frame with List component. By clicking button
"Selected Item" you can print current selected item index. If you click on item that is
already selected and then click on "Selected Item" button, you can see that this item
does not become unselected.
------------------------ test.java --------------------------------
import java.awt.*;
import java.awt.event.*;
public class test extends Frame implements ActionListener
{
List aList;
void init() {
aList= new List();
aList.add("Test item1");
aList.add("Test item2");
aList.add("Test item3");
Button aButton = new Button("Selected Item");
aButton.addActionListener(this);
Panel aPanel = new Panel();
aPanel.add(aList);
aPanel.add(aButton);
setSize(200,200);
add(aPanel);
}
public static void main(String [] argv)
{
test t = new test();
t.init();
t.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
System.out.println("Selected item is " + aList.getSelectedIndex());
}
}
======================================================================