United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6510999 Selection in a JList with both scrollbars visible jumps on arrowkey-down
JDK-6510999 : Selection in a JList with both scrollbars visible jumps on arrowkey-down

Details
Type:
Bug
Submit Date:
2007-01-09
Status:
Closed
Updated Date:
2011-05-18
Project Name:
JDK
Resolved Date:
2011-05-18
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
pressing arrow-key-down in a jlist with both scrollbars visible,
first visible index > 0 and select index > visible index makes the list
jumping down


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
you can test this with the attached small program.
just be sure to adjust the window to have both scrollbars visible,
scroll down to have the visible index > 0 then scroll up some items
and down again


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no jumping list
ACTUAL -
jumping list

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class JScrollBarTest {

  public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel p = new JPanel(new BorderLayout());
    JList l = new JList();
    DefaultListModel dlm = new DefaultListModel();
    for (int i = 0; i < 100; i++)
      dlm
        .addElement(i
          + " asdjafljasdlfu earp9tuepr9g uepr9t7u " + "wiphdfkjvnasdasdlasdjalsdaksdhaksdhaskjdhaskdhakdhasfkhsadlfh");
    l.setModel(dlm);
    JScrollPane s = new JScrollPane(l);
    l.setSelectedIndex(99);
    l.ensureIndexIsVisible(99);
    p.add(s, BorderLayout.CENTER);
    f.getContentPane().add(p);
    f.pack();
    f.setSize(new Dimension(200, 400));
    f.setVisible(true);
  }

}

---------- END SOURCE ----------

Release Regression From : 6
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

DELETED COMMENT
                                     
2007-01-12
EVALUATION

Use these instructions to reproduce:

Launch the test.
Scroll to the top.
Scroll down until item 20 is at the top.
Click on item 30.
Press the down arrow.
Notice how it jumps so that 30 is at the bottom.
                                     
2007-01-12
EVALUATION

The problem is in the BasicListUI.Actions.adjustScrollPositionIfNecessary() method

it does scrolling only if !visRect.contains(cellBounds)
(see it at the beginning of the method)

but when the list is too narrow to contain a long item
we do vertical scrolling even if there are enough vertical space
                                     
2007-08-20



Hardware and Software, Engineered to Work Together