How to get all top level window javafx?

前端 未结 3 1209
忘了有多久
忘了有多久 2021-01-13 05:38

I saw a method in AWT: java.awt.Window.getWindows(). In JavaFx, is there any method to get all window JavaFx application?

Thanks,

3条回答
  •  有刺的猬
    2021-01-13 06:23

    AFAIK, there is still no proper way to do this.

    Although there is a dirty and short term way :

    Browsing the source code of javafx.stage.Window, there is a static method which seems to do what you are expecting : javafx.stage.Window#impl_getWindows().

    But there is a bunch of disclaimers :

    /**
     * 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 impl_getWindows() {
        final Iterator iterator = AccessController.doPrivileged(
            new PrivilegedAction() {
                @Override public Iterator run() {
                    return windowQueue.iterator();
                }
            }
        );
        return iterator;
    }
    

提交回复
热议问题