简体   繁体   中英

Cannot Maximize Window with JavaFX

I made a custom Minimize button this way:

public MinimizeButton() {
    Button button = new Button("-");
    button.getStyleClass().clear();
    button.getStyleClass().add("actionbutton");
    button.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            Stage stage = (Stage) ((Button) event.getSource()).getScene().getWindow();
            stage.setIconified(true);
        }
    });
    this.getChildren().add(button);
}

And I obviously called

primaryStage.initStyle(StageStyle.UNDECORATED);

The button is working well.

The issue is that when I try to maximize the Window once the Stage is iconified, it takes a couple of seconds for the Window to redraw the Stage.

Any ideas on how to make the "Maximizing process" of the Window faster?

Fixed it by using

primaryStage.initStyle(StageStyle.TRANSPARENT);

instead of

primaryStage.initStyle(StageStyle.UNDECORATED);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM