Iconify stage on close, reopen it with the tray icon
This commit is contained in:
parent
2740a1cb10
commit
1d706c14f2
@ -54,7 +54,7 @@ public class StatusTrayIcon {
|
||||
final PopupMenu popup = new PopupMenu();
|
||||
|
||||
final MenuItem exitMenuItem = new MenuItem("Exit");
|
||||
exitMenuItem.addActionListener(evt -> System.exit(0));
|
||||
exitMenuItem.addActionListener(evt -> { Platform.exit(); System.exit(0); });
|
||||
popup.add(exitMenuItem);
|
||||
|
||||
trayIcon.setPopupMenu(popup);
|
||||
@ -63,7 +63,7 @@ public class StatusTrayIcon {
|
||||
stage.focusedProperty().addListener((ov, onHidden, onShown) -> displayMessages = ov.getValue());
|
||||
|
||||
// Show the window if the user clicks on the icon
|
||||
trayIcon.addActionListener(evt -> Platform.runLater(() -> { stage.show(); stage.requestFocus(); }));
|
||||
trayIcon.addActionListener(evt -> Platform.runLater(() -> { stage.setIconified(false); stage.toFront(); stage.requestFocus(); }));
|
||||
|
||||
// Start processing message events
|
||||
// TODO: Handle other message types
|
||||
|
@ -15,9 +15,7 @@ import javafx.scene.control.Alert.AlertType;
|
||||
import envoy.client.data.*;
|
||||
import envoy.client.net.Client;
|
||||
import envoy.client.net.WriteProxy;
|
||||
import envoy.client.ui.ClearableTextField;
|
||||
import envoy.client.ui.SceneContext;
|
||||
import envoy.client.ui.Startup;
|
||||
import envoy.client.ui.*;
|
||||
import envoy.data.LoginCredentials;
|
||||
import envoy.data.User;
|
||||
import envoy.data.User.UserStatus;
|
||||
@ -210,5 +208,16 @@ public final class LoginScene {
|
||||
sceneContext.getStage().setMinWidth(350);
|
||||
sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE);
|
||||
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
|
||||
|
||||
try {
|
||||
new StatusTrayIcon(sceneContext.getStage()).show();
|
||||
sceneContext.getStage().setOnCloseRequest(e -> {
|
||||
sceneContext.getStage().setIconified(true);
|
||||
e.consume();
|
||||
});
|
||||
} catch (EnvoyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user