简体   繁体   中英

How to attach Event Handler to JavaFX Stage/Window Minimize Button?

I need to hide the stage window when the window's minimize button is clicked. I'm doing everything is java code not in the scripting language. How can I attach a window event handler to a JavaFX stage window minimize button?

Attach a listener to your Stage's iconified property .

stage.iconifiedProperty().addListener(new ChangeListener<Boolean>() {
  @Override public void changed(ObservableValue<? extends Boolean> prop, Boolean oldValue, Boolean newValue) {
    System.out.println("Iconified? " + newValue);
  }
});

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