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


Question

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?

1
2
4/19/2012 7:24:26 PM

Accepted Answer

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);
  }
});
8
4/19/2012 9:23:10 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon