title: JavaFX: WindowEvent.WINDOW_HIDDEN
body: <p>I have written my own EventHandler, which does not do somethin special. It is just for practicing. Here he comes:</p>
  
  <pre><code>import javafx.event.EventHandler;
  import javafx.stage.WindowEvent;
  
  public class JavaFXMyWindowListener implements EventHandler&lt;WindowEvent&gt;{
  
      @Override
      public void handle(WindowEvent event) {
  
          System.out.println("WindowEvent: " +  event.getEventType());
  
          if(event.getEventType() == WindowEvent.WINDOW_CLOSE_REQUEST){
              System.out.println("Window closed");
              event.consume();
          }
  
          if(event.getEventType() == WindowEvent.WINDOW_SHOWING){
              System.out.println("Window activ");
          }
  
          if(event.getEventType() == WindowEvent.WINDOW_SHOWN){
              System.out.println("Window opened");
          }
  
          if(event.getEventType() == WindowEvent.WINDOW_HIDDEN){
              System.out.println("Window minimized");
          }
  
          if(event.getEventType() == WindowEvent.WINDOW_HIDING){
              System.out.println("Window is going to be minimized");
          }
  
      }
  
  }
  </code></pre>
  
  <p>I have problems with the last du if. WINDOW_HIDDEN &amp; WINDOW_HIDING dont seem to work, because that System.out never happens when i minimize the window. The other 3 Events work. Also the top most System.out doesnt occur, that means the event never happens. I have added the eventhandler as follow in the mainclass:</p>
  
  <pre><code>stage.addEventHandler(WindowEvent.ANY, new JavaFXMyWindowListener());
  </code></pre>
  
  <p>I have found the following workaround:</p>
  
  <pre><code>stage.iconifiedProperty().addListener(new ChangeListener&lt;Boolean&gt;() {
        @Override public void changed(ObservableValue&lt;? extends Boolean&gt; prop, Boolean oldValue, Boolean newValue) {
            if(newValue){
                System.out.println("Window minimized");
            }else{
                System.out.println("Window was minimized and gets back now");
            }
        }
  });
  </code></pre>
  
  <p>It is doing what i wanted to do, but why doesnt WINDOW_HIDDEN &amp; WINDOW_HIDING Working? i dont understand, please help. Thanks and regards.</p>