To do this, we will first design one of the windows where we create a button that, when pressed, will open an alert window of the selected type: information, caution, etc.
Each window or class in IntelliJ must have its corresponding FXML, which is shown below:
In this case, our main window will be devcodelight.fxml, where we have designed a button with the id btn_alerta.
To add the button, the following FXML code can be used:
The next step is to add the action to the button by adding an On Action attribute in the FXML:
We will create the method in the associated class (Devcodelight), declare the previously created button (in case we want to modify it in the future), and add the necessary code inside the method.
We have multiple options for the type of alert, but for this example, we will select the INFORMATION type.
Finally, we can execute the application and observe the result.
I hope this helps, regards!
Please note that the translation provided is an approximation and may not reflect the exact formatting or structure of the original content.
Open a Popup Window in IntelliJ from a Button
Tiempo de lectura: 2 minutos