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

Focus is off screen when tabbing through components in a ScrollPane

    XMLWordPrintable

Details

    • Cause Known
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      $ java -version
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      CYGWIN_NT-5.1 1.5.10(0.116/4/2) 2004-05-25 22:07 i686 unknown unknown Cygwin

      A DESCRIPTION OF THE PROBLEM :
      Focus goes off screen when tabbing through components in a ScrollPane. Tabbing through components works fine. However when components are within a scrollpane and successive components are off screen, tabbing through them will result in the component with the focus being off screen.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Save the html below as TabBug.html
      Save the java program below as TabBug.java
      Compile the java program: javac TabBug.java
      Run the applet: appletviewer TabBug.html
      Tab through the twenty TextFields.
      You'll notice that the focus leaves and enters each successive TextField.
      Tabbing through the latter TextFields, you'll notice they remain off screen.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      As tabbing through components progresses, the components off screen should become on screen as the focus enters each of the off screen TextFields (the vertical scroll bar should automatically scroll down).
      ACTUAL -
      Focus sequentially enters each of the successive components as tabbing occurs, however off screen components that have focus are non-viewable (are off screen) making it difficult to update those components (unless the user manually scrolls down to bring the focus into view).

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      TabBug.html
      -----------------------------
      <html>
      <head>
        <title>TabBug</title>
      </head>
      <body>

      <applet
       codebase="."
       code="TabBug"
       width="300"
       height="100">
      </applet>

      </body>
      </html>
      -----------------------------

      TabBug.java
      -----------------------------
      /**
       * @author Jeffrey Kutcher
       */
      public class TabBug extends javax.swing.JApplet {

          public void init() {
              javax.swing.JPanel panel = new javax.swing.JPanel();
              javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
              scrollPane.getVerticalScrollBar().setUnitIncrement(30);
              scrollPane.getHorizontalScrollBar().setUnitIncrement(30);
              scrollPane.setViewportView(panel);
              getContentPane().add(scrollPane);

              java.awt.GridBagLayout gbl = new java.awt.GridBagLayout();
              java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
              panel.setLayout(gbl);

              gbc.gridwidth = java.awt.GridBagConstraints.REMAINDER;

              java.awt.Container container;
              for (int i = 0; i < 20; ++i) {
                  container = new javax.swing.JTextField("TextField"+i, 15);
                  gbl.setConstraints(container, gbc);
                  panel.add(container);
              }
          }

      }
      -----------------------------

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

      CUSTOMER SUBMITTED WORKAROUND :
      Haven't found one yet.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dav Andrei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: