Lets say I have a simple alert.
Alert a = new Alert(AlertType.NONE);
CustomLabel lbl = new CustomLabel("Testing");
CustomButton ok = new CustomButton("OK");
FlowPane fp = new FlowPane();
fp.getChildren().addAll(lbl,ok);
alert.getDialogPane().setContent(fp);
alert.initStyle(StageStyle.TRANSPARENT);
Then I would like this to make this alert always on top of whatever screen I am showing, how do I do it?
Setting the stage of my main page to.
mainStage.setAlwaysOnTop(false); //does not work
Both my main and alert are to be on the same thread.
Meaning, on running my main, it will check for something then pop up the alert if something is not right.
Set your main stage to be always on top:
Then set your main stage to be owner of Alert dialog:
If main stage is owner of alert dialog, then alert will always be on top of main stage.