Code polish

This commit is contained in:
nathan 2016-10-08 21:50:37 +02:00
parent 000d069bfc
commit 381e629e72
3 changed files with 9 additions and 9 deletions

View File

@ -63,7 +63,7 @@ class SwingMenu extends Menu implements MenuEntry {
((SwingMenu) parent)._native.add(_native); ((SwingMenu) parent)._native.add(_native);
} else { } else {
// when we are the system tray // when we are the system tray
_native = new SwingSystemTrayMenuWindowsPopup(); _native = new SwingSystemTrayMenuPopup();
} }
} }
}); });
@ -329,8 +329,8 @@ class SwingMenu extends Menu implements MenuEntry {
public public
void run() { void run() {
_native.setVisible(false); _native.setVisible(false);
if (_native instanceof SwingSystemTrayMenuWindowsPopup) { if (_native instanceof SwingSystemTrayMenuPopup) {
((SwingSystemTrayMenuWindowsPopup) _native).close(); ((SwingSystemTrayMenuPopup) _native).close();
} }
SwingMenu parent = (SwingMenu) getParent(); SwingMenu parent = (SwingMenu) getParent();

View File

@ -185,19 +185,19 @@ class SwingSystemTray extends SwingMenu {
x -= size.width; // snap to edge of mouse x -= size.width; // snap to edge of mouse
} }
SwingSystemTrayMenuWindowsPopup popupMenu = (SwingSystemTrayMenuWindowsPopup) _native; SwingSystemTrayMenuPopup popupMenu = (SwingSystemTrayMenuPopup) _native;
popupMenu.doShow(x, y); popupMenu.doShow(x, y);
} }
}); });
try { try {
tray.add(trayIcon); tray.add(trayIcon);
((SwingSystemTrayMenuWindowsPopup) _native).setIcon(iconFile); ((SwingSystemTrayMenuPopup) _native).setIcon(iconFile);
} catch (AWTException e) { } catch (AWTException e) {
dorkbox.systemTray.SystemTray.logger.error("TrayIcon could not be added.", e); dorkbox.systemTray.SystemTray.logger.error("TrayIcon could not be added.", e);
} }
} else { } else {
((SwingSystemTrayMenuWindowsPopup) _native).setIcon(iconFile); ((SwingSystemTrayMenuPopup) _native).setIcon(iconFile);
trayIcon.setImage(trayImage); trayIcon.setImage(trayImage);
} }
} }

View File

@ -38,7 +38,7 @@ import dorkbox.util.OS;
* This custom popup is required, because we cannot close this popup by clicking OUTSIDE the popup. For whatever reason, that does not * This custom popup is required, because we cannot close this popup by clicking OUTSIDE the popup. For whatever reason, that does not
* work, so we must implement an "auto-hide" feature that checks if our mouse is still inside a menu every POPUP_HIDE_DELAY seconds * work, so we must implement an "auto-hide" feature that checks if our mouse is still inside a menu every POPUP_HIDE_DELAY seconds
*/ */
class SwingSystemTrayMenuWindowsPopup extends JPopupMenu { class SwingSystemTrayMenuPopup extends JPopupMenu {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// NOTE: we can use the "hidden dialog" focus window trick... only on windows and mac // NOTE: we can use the "hidden dialog" focus window trick... only on windows and mac
@ -46,7 +46,7 @@ class SwingSystemTrayMenuWindowsPopup extends JPopupMenu {
private volatile File iconFile; private volatile File iconFile;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
SwingSystemTrayMenuWindowsPopup() { SwingSystemTrayMenuPopup() {
super(); super();
setFocusable(true); setFocusable(true);
// setBorder(new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0)); // borderUI resource border type will get changed! // setBorder(new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0)); // borderUI resource border type will get changed!
@ -103,7 +103,7 @@ class SwingSystemTrayMenuWindowsPopup extends JPopupMenu {
this.hiddenDialog.addWindowFocusListener(new WindowFocusListener() { this.hiddenDialog.addWindowFocusListener(new WindowFocusListener() {
@Override @Override
public void windowLostFocus (WindowEvent we ) { public void windowLostFocus (WindowEvent we ) {
SwingSystemTrayMenuWindowsPopup.this.setVisible(false); SwingSystemTrayMenuPopup.this.setVisible(false);
} }
@Override @Override
public void windowGainedFocus (WindowEvent we) { public void windowGainedFocus (WindowEvent we) {