Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4368570
Votes 1
Synopsis unix: Clicking on a List item that is already selected does not deselect it
Category java:classes_awt
Reported Against mantis-rc , tiger-beta , mantis-beta , kestrel-linux
Release Fixed 1.5(tiger)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs 4909428
Submit Date 06-SEP-2000
Description





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());
    }
}

======================================================================
Work Around
N/A
Evaluation
 xxxxx@xxxxx  2003-05-20




A mistake was made in the java.awt.List class description of the doc
(see doc/api/java/awt/List.html).
Here is an excerpt from there:
---8<------------------------------------
For example, the code...

 List lst = new List(4, false);
 lst.add("Mercury");
 lst.add("Venus");
 lst.add("Earth");
 lst.add("JavaSoft");
 lst.add("Mars");
 lst.add("Jupiter");
 lst.add("Saturn");
 lst.add("Uranus");
 lst.add("Neptune");
 lst.add("Pluto");
 cnt.add(lst);

where cnt is a container, produces the following scrolling list: 

[an image]

Clicking on an item that isn't selected selects it. Clicking on
an item that is already selected deselects it.
In the preceding example, only one item from the scrolling list
can be selected at a time, since the second argument when
creating the new scrolling list is false. Selecting an item
causes any other selected item to be automatically deselected.
---8<------------------------------------

The sentences

  "Clicking on an item that isn't selected selects it.
   Clicking on an item that is already selected deselects it."

are true if a list is in a multiple-selection mode only. If a list
is in a single-selection mode, any click on list's item will
select a clicked item.
---

The Javadoc is changed to be more definite 
what happens if a java.awt.List component is in
a single-selection or a multiple-selection mode.
Please see suggested fix.
CCC decision, 2003/05/19

 xxxxx@xxxxx  2003-07-22

======================================================================
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang