Reputation: 395
I have a problem using the Alert
class in order to make a popup when pressing a certain button, for example when trying to change a variable, a popup would show up asking "Are you sure you want to change that?" and you could click on "Yes" or "No". The problem appears in a multi-screen setup, specifically when the main application is not on the main screen. If you click on the button that triggers this Alert
, then the popup will show up on the main screen, not on the current one. Is there a way to force it to show up on the current screen? Thank you.
This is an example of the popup:
Popup Example
Upvotes: 4
Views: 1327
Reputation: 72284
Use:
alert.initModality(Modality.APPLICATION_MODAL);
alert.initOwner(stage);
...before calling show()
or showAndWait()
on the alert, where stage
is the stage you want the alert to appear over.
Upvotes: 7