How to get all top level window javafx?


Question

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

Thanks,

1
5
3/6/2013 4:48:58 AM

Accepted Answer

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<Window> impl_getWindows() {
    final Iterator iterator = AccessController.doPrivileged(
        new PrivilegedAction<Iterator>() {
            @Override public Iterator run() {
                return windowQueue.iterator();
            }
        }
    );
    return iterator;
}
6
3/6/2013 10:18:53 AM

for javafx8 running java8 use

FXRobotHelper.getStages()
 or 
StageHelper.getStages()

This will retrieve all Stages which is essentially a Window itself ( it extends Window class)


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon