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

[macosx] TrayIcon does not handle mouseMoved event

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 9
    • client-libs
    • OS X 10.8.5

    • b11
    • 9
    • os_x

      Need to evaluate whether it is a bug or OS specific behavior.

      OS X. Created java.awt.TrayIcon does not handle mouseMoved event if the corresponding listener is added to it.
      It could be not a bug, like JDK-6827035 on Windows

      To reproduce run the following test:

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.image.BufferedImage;

      public class OSXMouseMovedTest {
          static boolean moved;

          public static void main(String[] args) throws Exception {
              moved = false;

              TrayIcon icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_3BYTE_BGR), "Test icon");
              icon.addMouseMotionListener(new MouseMotionAdapter() {
                  public void mouseMoved(MouseEvent event) {
                      moved = true;
                      System.out.println("Mouse moved");
                  }
              });
              SystemTray.getSystemTray().add(icon);

              Robot robot = new Robot();
              robot.mouseMove(0, 13);
              double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
              for (double i = width / 2; i <= width; i++){
                  robot.mouseMove((int) i, 13);
                  robot.delay(7);
              }

              if (!moved)
                  throw new RuntimeException("Mouse moved action did not trigger");
          }
      }

            pchelko Petr Pchelko (Inactive)
            dermashov Dmitriy Ermashov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: