I have an undecorated stage in a JavaFX Application. In order to minimize it I need a minimize button. I created my layout in an fxml document
which has a minimize button
, but when I try to minimize using the action listener
for this button located inside the controller using stage.setIconified(true)
, it cannot find stage.
How can I find a reference to the stage in the controller class?
You can try :
button.setOnAction(e -> {
((Stage)((Button)e.getSource()).getScene().getWindow()).setIconified(true);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With