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

REGRESSION: Tab key dosnt allways work

XMLWordPrintable

    • b53
    • x86
    • windows_xp

      FULL PRODUCT 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 :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When pressing tab in the supplied sample focus dosnt move when focus is in the textfield

      ###@###.### from the AWT team says: I think that this a bug in LayoutComparator. We have fixed several bugs in it and these fixes may unciver athoner problems in this class.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run sample
      Press tab key

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Focus in the checkbox
      ACTUAL -
      Focus in the textfield

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Dimension;
      import java.awt.GridBagConstraints;
      import java.awt.GridBagLayout;
      import java.awt.event.WindowEvent;

      import javax.swing.*;


      public class TabTester{
        public static void main(String[] args) {
          new TabTester();
        }
        public TabTester(){
          JFrame jf = new JFrame("aJFrame"){
            protected void processWindowEvent(WindowEvent e) {
              super.processWindowEvent(e);
              if (e.getID() == WindowEvent.WINDOW_CLOSING){
                System.exit(0);
              }
            }
          };
          jf.setVisible(true);
          JDialog dlg = new JDialog(jf, "aJDialog");
          
          JPanel panel = new JPanel(new GridBagLayout());
          JFormattedTextField ft = new JFormattedTextField();
          
          Dimension dim = new Dimension(100, ft.getPreferredSize().height);
          ft.setPreferredSize(dim);
          ft.setMinimumSize(dim);
          GridBagConstraints gc = new GridBagConstraints();
          gc.gridx=5;
          gc.gridy=1;
          gc.gridwidth=10;
          panel.add(ft, gc);
          
          gc.gridy=3;
          panel.add(new JCheckBox("aJCheckBox"), gc);
          
          gc.weightx = 1.0;
          gc.gridwidth = 1;
          gc.gridy = 0;
          gc.gridx = 0;
          
          for (int nCnt = 0; nCnt < 7; nCnt++) {
            gc.gridy++;
            panel.add(getlabel(), gc);
          }
          
          gc.gridx=0;
          gc.gridy=0;
          for (int nCnt = 0; nCnt < 7; nCnt++) {
            panel.add(getlabel(), gc);
            gc.gridx++;
          }
          dlg.getContentPane().add(panel);
          dlg.pack();
          dlg.setVisible(true);
        }
        
        private JLabel getlabel(){
          Dimension dim = new Dimension(5, 9); // Changing height to >=10 makes tab work, if its <10 it dosnt work
          JLabel aLabel = new JLabel(" ");
          aLabel.setMinimumSize(dim);
          aLabel.setMaximumSize(dim);
          aLabel.setPreferredSize(dim);
          return aLabel;
        }
      }
      ---------- END SOURCE ----------

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-2-09 22:53:08 GMT
      ###@###.### 2005-07-07 12:51:31 GMT

            ant Anton Tarasov (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: