code polish
This commit is contained in:
parent
3916f2cd1d
commit
5c2dc1fdc6
|
@ -138,15 +138,14 @@ class SwingSystemTray extends dorkbox.systemTray.SystemTray {
|
||||||
SwingSystemTray tray = SwingSystemTray.this;
|
SwingSystemTray tray = SwingSystemTray.this;
|
||||||
synchronized (tray) {
|
synchronized (tray) {
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
|
// here we init. everything
|
||||||
isActive = true;
|
isActive = true;
|
||||||
|
|
||||||
SwingSystemTray.this.menu = new SwingSystemTrayMenuPopup();
|
menu = new SwingSystemTrayMenuPopup();
|
||||||
|
|
||||||
Image trayImage = new ImageIcon(iconPath).getImage()
|
Image trayImage = new ImageIcon(iconPath).getImage()
|
||||||
.getScaledInstance(TRAY_SIZE, TRAY_SIZE, Image.SCALE_SMOOTH);
|
.getScaledInstance(TRAY_SIZE, TRAY_SIZE, Image.SCALE_SMOOTH);
|
||||||
trayImage.flush();
|
trayImage.flush();
|
||||||
final TrayIcon trayIcon = new TrayIcon(trayImage);
|
trayIcon = new TrayIcon(trayImage);;
|
||||||
SwingSystemTray.this.trayIcon = trayIcon;
|
|
||||||
|
|
||||||
// appindicators don't support this, so we cater to the lowest common denominator
|
// appindicators don't support this, so we cater to the lowest common denominator
|
||||||
// trayIcon.setToolTip(SwingSystemTray.this.appName);
|
// trayIcon.setToolTip(SwingSystemTray.this.appName);
|
||||||
|
@ -155,7 +154,6 @@ class SwingSystemTray extends dorkbox.systemTray.SystemTray {
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
void mousePressed(MouseEvent e) {
|
void mousePressed(MouseEvent e) {
|
||||||
final SwingSystemTrayMenuPopup menu = SwingSystemTray.this.menu;
|
|
||||||
Dimension size = menu.getPreferredSize();
|
Dimension size = menu.getPreferredSize();
|
||||||
|
|
||||||
Point point = e.getPoint();
|
Point point = e.getPoint();
|
||||||
|
@ -182,11 +180,13 @@ class SwingSystemTray extends dorkbox.systemTray.SystemTray {
|
||||||
x -= size.width; // snap to edge of mouse
|
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.setInvoker(menu);
|
||||||
menu.setLocation(x, y);
|
menu.setLocation(x, y);
|
||||||
menu.setVisible(true);
|
menu.setVisible(true);
|
||||||
menu.requestFocus();
|
menu.setFocusable(true);
|
||||||
|
menu.requestFocusInWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user