How to use the Window event in JavaFX

How to use the Window event in JavaFX

Mar 02, 2022

JavaFX Tutorial

Window event in JavaFX is part of the javafx.stage package in JavaFX. If you are just getting started with Java programming, you should also learn about window events. In Java, the window event contains four constants: WINDOW_SHOWINGWINDOWSHOWN, WINDOWHIDINGWINDOW_HIDDEN, and WINDOWCLOSEREQUEST.

Window Event in JavaFX

The WindowEvent class in JavaFX is easy to understand and the constants in the WindowEvent class in JavaFX are listed below.

  • WINDOW_SHOWING – This type of event will occur just before the window is shown.

  • WINDOW_SHOWN – This type of event will occur just after the window is shown.

  • WINDOW_HIDING – This type of event will occur just before the window is hidden.

  • WINDOW_HIDDEN – This type of event will occur just after the window is hidden.

  • WINDOWCLOSEREQUEST – This type of event will occur if the developer generated the window close event in Java to close the window.

The WINDOWSHOWING and WINDOWSHOWN events are quick. This events will be generated just before and after the window is shown. If you use the WINDOW_SHOWING event, it might delay the displaying of the window to the user and degrading to the user experience.

Read more window event in JavaFX

Enjoy this post?

Buy Kensoft PH a glass of milk

More from Kensoft PH