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

Auto focus transfer to disabled component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1, 1.4.1
    • client-libs
    • generic, x86
    • generic, windows_2000

      Run the test case below. Click on button two. This disables button two and three. However, the auto focus transfer from the disabling of button two causes focus to go to the also disabled button three, and it can't be moved with tab traversal.

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

      public class ButTest extends JFrame {

          private JButton one = new JButton("one");
          private JButton two = new JButton("two");
          private JButton three = new JButton("three");
          private JButton four = new JButton("four");


          public ButTest() {
              super("ButTest");

              setLayout(new FlowLayout());
              add(one);
              add(two);
              add(three);
              add(four);

              two.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ae) {
                      two.setEnabled(false);
                      three.setEnabled(false);
                  }
              });
          }

          private static void createAndShowGUI(String[] args) {
              ButTest test = new ButTest();
              test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              test.setSize(400, 400);
              test.setLocationRelativeTo(null);
              test.setVisible(true);
          }

          public static void main(final String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI(args);
                  }
              });
          }
      }

            ant Anton Tarasov (Inactive)
            shickeysunw Shannon Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: