Code polish
This commit is contained in:
parent
000d069bfc
commit
381e629e72
@ -63,7 +63,7 @@ class SwingMenu extends Menu implements MenuEntry {
|
||||
((SwingMenu) parent)._native.add(_native);
|
||||
} else {
|
||||
// when we are the system tray
|
||||
_native = new SwingSystemTrayMenuWindowsPopup();
|
||||
_native = new SwingSystemTrayMenuPopup();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -329,8 +329,8 @@ class SwingMenu extends Menu implements MenuEntry {
|
||||
public
|
||||
void run() {
|
||||
_native.setVisible(false);
|
||||
if (_native instanceof SwingSystemTrayMenuWindowsPopup) {
|
||||
((SwingSystemTrayMenuWindowsPopup) _native).close();
|
||||
if (_native instanceof SwingSystemTrayMenuPopup) {
|
||||
((SwingSystemTrayMenuPopup) _native).close();
|
||||
}
|
||||
|
||||
SwingMenu parent = (SwingMenu) getParent();
|
||||
|
@ -185,19 +185,19 @@ class SwingSystemTray extends SwingMenu {
|
||||
x -= size.width; // snap to edge of mouse
|
||||
}
|
||||
|
||||
SwingSystemTrayMenuWindowsPopup popupMenu = (SwingSystemTrayMenuWindowsPopup) _native;
|
||||
SwingSystemTrayMenuPopup popupMenu = (SwingSystemTrayMenuPopup) _native;
|
||||
popupMenu.doShow(x, y);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
tray.add(trayIcon);
|
||||
((SwingSystemTrayMenuWindowsPopup) _native).setIcon(iconFile);
|
||||
((SwingSystemTrayMenuPopup) _native).setIcon(iconFile);
|
||||
} catch (AWTException e) {
|
||||
dorkbox.systemTray.SystemTray.logger.error("TrayIcon could not be added.", e);
|
||||
}
|
||||
} else {
|
||||
((SwingSystemTrayMenuWindowsPopup) _native).setIcon(iconFile);
|
||||
((SwingSystemTrayMenuPopup) _native).setIcon(iconFile);
|
||||
trayIcon.setImage(trayImage);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
* 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;
|
||||
|
||||
// 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;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
SwingSystemTrayMenuWindowsPopup() {
|
||||
SwingSystemTrayMenuPopup() {
|
||||
super();
|
||||
setFocusable(true);
|
||||
// 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() {
|
||||
@Override
|
||||
public void windowLostFocus (WindowEvent we ) {
|
||||
SwingSystemTrayMenuWindowsPopup.this.setVisible(false);
|
||||
SwingSystemTrayMenuPopup.this.setVisible(false);
|
||||
}
|
||||
@Override
|
||||
public void windowGainedFocus (WindowEvent we) {
|
Loading…
Reference in New Issue
Block a user