How to make the window just disappear when you click on the button?

the application will require one and only one instance of this window, change the value of the defaultCloseOperation property to HIDE (that is, by clicking on the close button of the window it should just hide).

This is for Swing how to do this for JavaFX.

    1 answer 1

    You need to handle the event closeRequest

     this.stage.setOnCloseRequest(windowEvent - > { stage.hide(); }); 

    If you want the application to simply collapse, you need to do so.

     this.stage.setOnCloseRequest(windowEvent - > { stage.setIconified(true); });