Remove cycle between SystemTray and BitsquareUI

This commit is contained in:
Chris Beams 2014-11-04 12:07:21 +01:00
parent b1a4641139
commit f278db01ac
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
2 changed files with 5 additions and 10 deletions

View File

@ -109,7 +109,7 @@ public class BitsquareUI extends Application {
// configure the system tray
SystemTray systemTray = new SystemTray(primaryStage, this);
SystemTray systemTray = new SystemTray(primaryStage, this::stop);
primaryStage.setOnCloseRequest(e -> systemTray.hideStage());
scene.setOnKeyReleased(keyEvent -> {
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent))

View File

@ -17,7 +17,6 @@
package io.bitsquare.gui;
import io.bitsquare.BitsquareUI;
import io.bitsquare.gui.util.ImageUtil;
import java.awt.*;
@ -43,13 +42,13 @@ public class SystemTray {
public static final String HIDE_WINDOW_LABEL = "Hide exchange window";
private final Stage stage;
private final BitsquareUI application;
private final Runnable onExit;
private final TrayIcon trayIcon = createTrayIcon();
private final MenuItem toggleShowHideItem = new MenuItem(HIDE_WINDOW_LABEL);
public SystemTray(Stage stage, BitsquareUI application) {
public SystemTray(Stage stage, Runnable onExit) {
this.stage = stage;
this.application = application;
this.onExit = onExit;
init();
}
@ -95,11 +94,7 @@ public class SystemTray {
exitItem.addActionListener(e -> {
self.remove(trayIcon);
try {
application.stop();
} catch (Exception ex) {
log.error("Application failed to shut down properly.", ex);
}
onExit.run();
});
}