JDK-4337119 : SelectAll and RemoveAll in Jlist alters anchor and lead
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-05-10
  • Updated: 2004-04-26
  • Resolved: 2004-04-26
Related Reports
Duplicate :  
Description

Name: skT45625			Date: 05/10/2000


java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-U)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)

String [] data = {"one","two","three","four", "five", "six", "seven"};
javax.swing.JList JList2 = new javax.swing.JList( data );
sp2 = new javax.swing.JScrollPane(JList2);
sp2.setBounds( new java.awt.Rectangle( 450,100,100,100 ) );
JList2.setCellRenderer( new javax.swing.DefaultListCellRenderer() );
JList2.setName( "JList2" );
JList2.setValueIsAdjusting(false);
JList2.setSelectedIndices( new int[]{} );
JList2.setSelectionModel( new javax.swing.DefaultListSelectionModel(  ) );
add(sp2);

select seven in the list. it should be set as the selectedindex. Hold down
control and click on three. Both seven and three should be selected, but three
should be the lead. Hold down control and press a to select all. Three should
stay as the lead, but the lead changes to the last item on the list, which is
seven. The listbox does not scroll down to make it visible if it is not.
Removing all works similar. Instead of pressing control-a, press control-\.
(Review ID: 103015) 
======================================================================

Comments
EVALUATION Name: apR10133 Date: 12/28/2001 The problem is that anchor and lead selection indices are updated when we press keyboard shortcut (Ctrl-A) for "select all" on JList. This happens because we call method setSelectionInterval() which always updates lead/anchor indices. The current API of DefaultListSelectionModel doesn't allow us to set the selection interval without affecting the lead/anchor indices. ###@###.### ====================================================================== This has actually been fixed by the changes done in 4303294. ###@###.### 2004-04-26
11-06-2004