Jpanel having weird tab-key issues

38 views Asked by At

I'm having an issue with a Jpanel. When a user enters the first box and tabs, it takes them to the third box, then back to the second, then fourth fifth and sixth. Does anyone have any ideas why it would do this?

      JPanel myPanel = new JPanel();
      myPanel.add(new JLabel("L1:"));
      myPanel.add(L1);
      myPanel.add(Box.createHorizontalStrut(15)); // a spacer
      myPanel.add(new JLabel("L2:"));
      myPanel.add(L2);
      myPanel.add(Box.createHorizontalStrut(15)); // a spacer
      myPanel.add(new JLabel("L3:"));
      myPanel.add(L3);
      myPanel.add(Box.createHorizontalStrut(15)); // a spacer
      myPanel.add(new JLabel("L4:"));
      myPanel.add(L4);
      myPanel.add(Box.createHorizontalStrut(15)); // a spacer
      myPanel.add(new JLabel("L5:"));
      myPanel.add(L5);
      myPanel.add(Box.createHorizontalStrut(15)); // a spacer
      myPanel.add(new JLabel("East:"));
      myPanel.add(LE);
      myPanel.add(Box.createHorizontalStrut(15)); // a spacer
      myPanel.add(new JLabel("CF:"));
      myPanel.add(CF);
1

There are 1 answers

0
prmottajr On

You should set the tab order for your components. If not set it will use the order in which objects are created.