JavaFX Tutorial
In this tutorial, you will learn to minimize an undecorated window in JavaFX. If you are developing an application and that is an undecorated window and wonder how to minimize your stage or window in JavaFX. Alright, let’s get started.
How to minimize an undecorated window in JavaFX
To minimize the undecorated window or stage in JavaFX. We will call the setIconified() method. The setIconified() method has a parameter with a boolean data type. We can set the parameter in the setIconified() it’s either true or false.
To implement it in the code, you will need to cast the stage in your JavaFX controller and define the node from your stage. To achieve the minimize code in JavaFX, kindly see the example code below.
Example
In this example, I will show you the code to minimize the undecorated window or stage in JavaFX. So, let’s assume that I have a Minimize button and it is called by minmize_button. Implement this code in your JavaFX controller. Try it now and see the result.
@FXML private void Minimize_clicked(MouseEvent event) { Stage stage = (Stage) minimize_button.getScene().getWindow(); stage.setIconified(true); }