

So once this pop up window appears, you cannot interact with any other window, including the main The line, popupwindow.initModality(Modality.APPLICATION_MODAL) ,ĭefines a window that blocks events from being delivered to any other application window. So we have to create a new stage in order to get a new window. In JavaFX, a newĪ stage represents a window. Since this pop up window is a new window separate from the main window, we must create a new window. The first thing we do in this method is create a new Stage. In the main program using the class name (Popup) followed by the method, display(). The method is static so that we can just call the class in the main program instead of having to create an instance of this class. In this method, we create how the window will look like. In this class, we add a method named display(). We then import all the packages we need into our program so that it works.

The package in this example is called firstgui. So being that we are using multiple classes, we must contain a package statement in the classes.
