我在AWT中看到了一个方法:java.awt.Window.getWindows()
。 在JavaFx中,是否有任何方法可以获得所有窗口JavaFx应用程序?如何获得所有顶级窗口javafx?
谢谢,
我在AWT中看到了一个方法:java.awt.Window.getWindows()
。 在JavaFx中,是否有任何方法可以获得所有窗口JavaFx应用程序?如何获得所有顶级窗口javafx?
谢谢,
AFAIK,仍然没有正确的方法来做到这一点。
虽然有脏和短期方式:
浏览source code of javafx.stage.Window
,有这似乎是你期待什么静态方法:javafx.stage.Window#impl_getWindows()
。
但有一堆免责声明的:
/**
* Return all Windows
*
* @return Iterator of all Windows
* @treatAsPrivate implementation detail
* @deprecated This is an internal API that is not intended for use and will be removed in the next version
*/
@Deprecated
@NoInit
public static Iterator<Window> impl_getWindows() {
final Iterator iterator = AccessController.doPrivileged(
new PrivilegedAction<Iterator>() {
@Override public Iterator run() {
return windowQueue.iterator();
}
}
);
return iterator;
}
这已经在Java 9中得到了最终修正。请参见javafx.stage.Window.getWindows()
返回包含对当前显示的JavaFX 窗口的引用的列表。该列表不可修改 - 尝试修改此列表 将导致在运行时抛出UnsupportedOperationException。
为涉及StageHelper
或FXRobotHelper
其他解决方案不再可能,因为这些在com.sun.javafx
包,它不再能够访问存在这是Java 9是必不可少的。
该方法仅在当前进程中列出一个Window JavaFX。请为我的结果发表评论? – 2013-03-07 13:21:49
'java.awt.Window.getWindows()'的工作方式。它返回jre中的所有窗口。 – gontard 2013-03-07 13:23:49
@ gontard不,它不。我打开了几个javafx窗口,但awt.Window方法仍然返回一个空数组。 – Renato 2014-03-29 12:20:05