JavaFX 检测舞台屏幕位置的变化

标签 java javafx window stage

JavaFX 中有没有办法检测舞台/窗口位置相对于屏幕何时发生变化?

我可以检测到何时调整舞台大小,但无法检测到何时重新定位舞台。

最佳答案

您可以使用xPropertyyProperty 窗口

The horizontal location of this Stage on the screen. Changing this attribute will move the Stage horizontally. Changing this attribute will not visually affect a Stage while fullScreen is true, but will be honored by the Stage once fullScreen becomes false.

stage.xProperty().addListener((obs, oldVal, newVal) -> System.out.println("X: " + newVal));
stage.yProperty().addListener((obs, oldVal, newVal) -> System.out.println("Y: " + newVal));

关于JavaFX 检测舞台屏幕位置的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38047119/

相关文章:

java - 如何在liferay中使用集合

java - 在 JavaScript 下拉列表中显示对象的值

JavaFX Webview 在 polymer Material 设计元素上出现故障

java - 如何在javafx时间轴中不断更改键值的目标值?

objective-c - Xcode:窗口动画

python - 如何删除python中的诅咒窗口并恢复背景窗口?

java - 在不使用外部存储器的情况下在 Java 上保存对象状态

java - 错误 - trustAnchors 参数必须非空

binding - 无法设置 Javafx 组合框绑定(bind)值异常

c++ - Eclipse C++ MinGW - 无法启动程序<已终止>