Add an option to not use systray

This commit is contained in:
Laurent Clouet
2016-04-28 19:37:05 +02:00
parent 783475b7fa
commit 718316cb38
2 changed files with 22 additions and 15 deletions

View File

@@ -59,6 +59,7 @@ public class GuiSwing extends JFrame implements Gui {
private Working activityWorking;
private Settings activitySettings;
private TrayIcon trayIcon;
private boolean useSysTray;
private int framesRendered;
@@ -67,9 +68,9 @@ public class GuiSwing extends JFrame implements Gui {
private ThreadClient threadClient;
public GuiSwing() {
public GuiSwing(boolean useSysTray_) {
framesRendered = 0;
useSysTray = useSysTray_;
waitingForAuthentication = true;
}
@@ -82,21 +83,24 @@ public class GuiSwing extends JFrame implements Gui {
e1.printStackTrace();
}
try {
sysTray = SystemTray.getSystemTray();
if (SystemTray.isSupported()) {
addWindowStateListener(new WindowStateListener() {
public void windowStateChanged(WindowEvent e) {
if (e.getNewState() == ICONIFIED) {
hideToTray();
if (useSysTray) {
try {
sysTray = SystemTray.getSystemTray();
if (SystemTray.isSupported()) {
addWindowStateListener(new WindowStateListener() {
public void windowStateChanged(WindowEvent e) {
if (e.getNewState() == ICONIFIED) {
hideToTray();
}
}
}
});
});
}
}
catch (UnsupportedOperationException e) {
sysTray = null;
}
}
catch (UnsupportedOperationException e) {
sysTray = null;
}
URL iconUrl = getClass().getResource("/icon.png");
if (iconUrl != null) {