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

JScrollPane scrolls beyond beginning when PAGE_UP key is pressed

    XMLWordPrintable

Details

    • kestrel
    • generic
    • generic

    Description



      Name: skT88420 Date: 09/24/99


      In some cases, JScrollPane scrolls beyond the beginning
      of the viewport contents when the PAGE_UP key is
      pressed while the view position is at (0,0). Please
      take a look at the test program below. If I press
      PAGE_UP after starting the program, the viewport
      contents disappear. They only become visible again
      after hitting PAGE_DOWN or moving the scroll bar.
      Maybe some kind of additional check is needed in
      BasicScrollPaneUI.ScrollAction.

      ---

      import java.awt.*;
      import javax.swing.*;

      public class JScrollPaneBug extends JDialog {
        public JScrollPaneBug() {
          super((Frame) null, "JScrollPane bug", true);
          
          JScrollPane scp = new JScrollPane();
          
          JPanel pnl = new JPanel();
          pnl.setLayout(new GridBagLayout());
          
            for (int i = 1; i <= 50; i++) {
              JTextField tf = new JTextField();
              tf.setText("Text field no." + i);
              pnl.add(tf, new GridBagConstraints(
                0, GridBagConstraints.RELATIVE, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets(0, 0, 0, 0), 0, 0));
            }
          
          scp.getViewport().add(pnl);
          
          getContentPane().add(scp);
          
          setSize(new Dimension(400, 300));
          setVisible(true);
        }
        
        public static void main(String args[]) {
          new JScrollPaneBug();
          System.exit(0);
        }
      }
      (Review ID: 95677)
      ======================================================================

      Attachments

        Activity

          People

            svioletsunw Scott Violet (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: