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

Swing apps take input focus on launch regardless of window manager policy

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • None
    • solaris
    • client-libs
    • generic
    • solaris_nevada

      [dep, 02May2007]

        I've noticed that on recent builds, regardless of window manager
        settings to the contrary, swing applications take input focus
        immediately on startup. This is really annoying behavior, especially
        if I'm in the middle of typing something sensitive in the window that
        looses focus.

        Setting AWT_TOOLKIT=MToolkit makes the problem go away. (At least on
        SPARC; on x86 I get font errors which ultimately result in an NPE).

        A simple test program which exhibits the problem:

              import javax.swing.*;

              public class Test implements Runnable
              {
                      public static void main(String args[])
                      {
                              SwingUtilities.invokeLater(new Test());
                      }

                      public synchronized void run()
                      {
                              assert (SwingUtilities.isEventDispatchThread());

                              JFrame frame = new JFrame("Test");
                              frame.add(new JLabel("Hello World"));

                              frame.pack();
                              frame.setVisible(true);
                      }
              }

            ant Anton Tarasov (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: