Ok, I inserted this code right above the call to showDialog()
:
alert.boundsInParentProperty().addListener((prop, oldBounds, newBounds) -> {
alert.setLayoutX(screenWidthProperty.get() * 0.5 - newBounds.getWidth() * 0.5);
alert.setLayoutY(screenHeightProperty.get() * 0.5 - newBounds.getHeight() * 0.5);
});
It centers perfectly. I’ll try moving this to showDialog()
and see how it goes.
(The screen width/height properties are JavaFX properties in my own code that track the screen width/height respectively.)