diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index cae033967..05d3b69a9 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -79,7 +79,9 @@ public final class MainPage extends StackPane implements DecoratorPage { private final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(); private final PopupMenu menu = new PopupMenu(); - private final JFXPopup popup = new JFXPopup(menu); + + private final StackPane popupWrapper = new StackPane(menu); + private final JFXPopup popup = new JFXPopup(popupWrapper); private final StringProperty currentGame = new SimpleStringProperty(this, "currentGame"); private final BooleanProperty showUpdate = new SimpleBooleanProperty(this, "showUpdate"); @@ -321,15 +323,27 @@ public final class MainPage extends StackPane implements DecoratorPage { } private void onMenu() { + Node contentNode; if (menu.getContent().isEmpty()) { Label placeholder = new Label(i18n("version.empty")); placeholder.setStyle("-fx-padding: 10px; -fx-text-fill: gray; -fx-font-style: italic;"); - - popup.setPopupContent(placeholder); + contentNode = placeholder; } else { - popup.setPopupContent(menu); + contentNode = menu; } - popup.show(menuButton, JFXPopup.PopupVPosition.BOTTOM, JFXPopup.PopupHPosition.RIGHT, 0, -menuButton.getHeight()); + + popupWrapper.getChildren().setAll(contentNode); + + if (popup.isShowing()) { + popup.hide(); + } + popup.show( + menuButton, + JFXPopup.PopupVPosition.BOTTOM, + JFXPopup.PopupHPosition.RIGHT, + 0, + -menuButton.getHeight() + ); } private void onUpgrade() {