From 5c2dc1fdc6a33f2417fdb250847e775f73df84b2 Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 21 Feb 2016 00:55:54 +0100 Subject: [PATCH] code polish --- src/dorkbox/systemTray/swing/SwingSystemTray.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dorkbox/systemTray/swing/SwingSystemTray.java b/src/dorkbox/systemTray/swing/SwingSystemTray.java index 8e884ef..ac83148 100644 --- a/src/dorkbox/systemTray/swing/SwingSystemTray.java +++ b/src/dorkbox/systemTray/swing/SwingSystemTray.java @@ -138,15 +138,14 @@ class SwingSystemTray extends dorkbox.systemTray.SystemTray { SwingSystemTray tray = SwingSystemTray.this; synchronized (tray) { if (!isActive) { + // here we init. everything isActive = true; - SwingSystemTray.this.menu = new SwingSystemTrayMenuPopup(); - + menu = new SwingSystemTrayMenuPopup(); Image trayImage = new ImageIcon(iconPath).getImage() .getScaledInstance(TRAY_SIZE, TRAY_SIZE, Image.SCALE_SMOOTH); trayImage.flush(); - final TrayIcon trayIcon = new TrayIcon(trayImage); - SwingSystemTray.this.trayIcon = trayIcon; + trayIcon = new TrayIcon(trayImage);; // appindicators don't support this, so we cater to the lowest common denominator // trayIcon.setToolTip(SwingSystemTray.this.appName); @@ -155,7 +154,6 @@ class SwingSystemTray extends dorkbox.systemTray.SystemTray { @Override public void mousePressed(MouseEvent e) { - final SwingSystemTrayMenuPopup menu = SwingSystemTray.this.menu; Dimension size = menu.getPreferredSize(); Point point = e.getPoint(); @@ -182,11 +180,13 @@ class SwingSystemTray extends dorkbox.systemTray.SystemTray { x -= size.width; // snap to edge of mouse } - // weird voodoo to get this to popup with the correct parent + // voodoo to get this to popup to have the correct parent + // from: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6285881 menu.setInvoker(menu); menu.setLocation(x, y); menu.setVisible(true); - menu.requestFocus(); + menu.setFocusable(true); + menu.requestFocusInWindow(); } });