Duplicate :
|
|
Relates :
|
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"); } }