Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6568906

Unnecessary scrolling in JLIst/BasicListUI if JList is wider than the viewport

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      adjustScrollPositionIfNecessary(JList list, int index, int direction) in BasicListUI should only use y and height when it checks to see if cell is visible. If the cell is wider than the viewport it will always try to scroll.

      JUSTIFICATION :
        Customer complains

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Run the test case.
      Scroll down to make cell 6 to 13 visible.
      Select cell 9.
      Use down key to select cell 10.
      Cell 10 should be selected without scrolling.
      ACTUAL -
      Run the test case.
      Scroll down to make cell 6 to 13 visible.
      Select cell 9.
      Use down key to select cell 10.
      Cell 10 is selected and cell 3 to 10 is now visible.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.util.Vector;

      import javax.swing.*;

      public class Main extends JDialog {
        private static final long serialVersionUID = 7373795962525653313L;

        public static void main(String[] args) {
          try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          }
          catch (Exception exception) {
            exception.printStackTrace();
          }
          Main dlg = new Main(null);
          dlg.setVisible(true);
          System.exit(0);
        }

        public Main(Frame owner) {
          super(owner,true);
          Vector<String> strings = new Vector<String>();
          for(int i=1; i<20; i++)
            strings.add(String.format("Long text string %d ..............",i));
          JList jList = new JList(strings);
          JScrollPane jScrollPane = new JScrollPane(jList);
          JPanel jContentPane = new JPanel();
          jContentPane.setLayout(new BorderLayout());
          jContentPane.add(jScrollPane, BorderLayout.CENTER);
          this.setBounds(new Rectangle(0, 0, 100, 200));
          this.setContentPane(jContentPane);
        }
      }

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ryeung Roger Yeung (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: