Won't capture mouse movement events after maximizing or full screening a window

XMLWordPrintable

    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.7.0_51"
      Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OS X 10.9.1 (13B3116) and previous releases

      A DESCRIPTION OF THE PROBLEM :
      When enlarging a window by either pressing the maximize button or the full screen button on OS X, mouse movement events are no longer captured (though dragging events are).

      The maximization problem can be replicated using the MouseEventDemo web start example (http://docs.oracle.com/javase/tutorialJWS/samples/uiswing/MouseEventDemoProject/MouseEventDemo.jnlp) on the Java Tutorials website, as well as via the executable test case submitted here.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Enlarge a window by either pressing the maximize button or the full screen button on OS X.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Mouse events should be continue being captured after maximizing or full screening a window.
      ACTUAL -
      Mouse events are no longer captured after maximizing or full screening a window.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.EventQueue;
      import java.awt.Window;
      import java.awt.event.MouseEvent;
      import java.awt.event.MouseMotionListener;
      import java.lang.reflect.Method;
      import javax.swing.JFrame;
      import javax.swing.JLabel;

      public class Main implements MouseMotionListener {

          JLabel label = new JLabel("label");

          public static void main(String[] args) {
              EventQueue.invokeLater(new Runnable() {
                  public void run() {
                      Main main = new Main();
                      main.init();
                  }
              });
          }

          public void init() {
              final JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.add(label);
              frame.pack();
              frame.setSize(640, 480);
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
              if (isMacOSX()) {
                  enableFullScreenMode(frame);
              }
              frame.addMouseMotionListener(this);
          }

          public void mouseDragged(MouseEvent e) {
              label.setText(e.toString());
          }

          public void mouseMoved(MouseEvent e) {
              label.setText(e.toString());
          }

          private static boolean isMacOSX() {
              return System.getProperty("os.name").indexOf("Mac OS X") >= 0;
          }

          public static void enableFullScreenMode(Window window) {
              try {
                  Class<?> clazz = Class.forName("com.apple.eawt.FullScreenUtilities");
                  Method method = clazz.getMethod("setWindowCanFullScreen",
                          new Class<?>[]{Window.class, boolean.class});
                  method.invoke(null, window, true);
              } catch (Throwable t) {
                  t.printStackTrace();
              }
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Note that mouse movements are recaptured if the mouse leaves the window (e.g., moves to the top of the window to access the menu bar) and then returns. However, no programmatic workaround is known.

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: