Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
Change to singleton window
Browse files Browse the repository at this point in the history
  • Loading branch information
kphrx committed Oct 15, 2018
1 parent 25c3fd0 commit 47db5ff
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
import logbook.plugin.gui.MainExtMenu;

public class KanmusuListGeneratorMenu implements MainExtMenu {
private static Stage stage = null;

@Override
public MenuItem getContent() {
MenuItem menu = new MenuItem("艦隊晒しフォーマット");
menu.setOnAction(e -> {
if (this.stage != null) {
this.stage.toFront();
return;
}

try {
Stage stage = new Stage();
URL url = KanmusuListGeneratorMenu.class.getClassLoader()
Expand All @@ -35,7 +41,9 @@ public MenuItem getContent() {
Tools.Windows.setIcon(stage);
Tools.Windows.defaultCloseAction(controller);
Tools.Windows.defaultOpenAction(controller);
stage.show();
stage.setOnCloseRequest(event -> this.stage = null);
this.stage = stage;
this.stage.show();
} catch (Exception ex) {
LoggerHolder.get().warn("艦隊晒しフォーマットを開けませんでした", ex);
}
Expand Down

0 comments on commit 47db5ff

Please sign in to comment.