我有一个JavaFx应用程序,其中显示了一些警报/对话框,但是在多屏幕环境中,当该应用程序移至辅助屏幕时,这些警报/对话框仍会显示在主屏幕上。
如何在应用程序所在的同一屏幕上(自动)显示那些(非模态)对话框?
您只需要设置对话框的所有者:
dialog.initOwner(primaryStage)
并确保您之前不打电话 primaryStage.show()
要检测应用程序显示在哪个屏幕上,可以使用主屏幕的边界:
private boolean isOnPrimaryScreen(double x) {
Rectangle2D bounds = Screen.getPrimary().getBounds();
return x <= bounds.getMaxX();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句