Example usage for java.awt Window getOwnerlessWindows

List of usage examples for java.awt Window getOwnerlessWindows

Introduction

In this page you can find the example usage for java.awt Window getOwnerlessWindows.

Prototype

public static Window[] getOwnerlessWindows() 

Source Link

Document

Returns an array of all Window s created by this application that have no owner.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    JDialog d1 = new JDialog((JFrame) null, "Dialog 1");
    d1.setName("Dialog 1");

    JDialog d2 = new JDialog((Window) null, "Dialog 2");
    d2.setName("Dialog 2");

    Frame f = new Frame();
    f.setName("Frame 1");

    Window w1 = new Window(f);
    w1.setName("Window 1");

    Window w2 = new Window(null);
    w2.setName("Window 2");

    Window[] ownerlessWindows = Window.getOwnerlessWindows();
    for (Window window : ownerlessWindows)
        System.out.println(window.getName() + ": " + window.getClass());

}

From source file:com.github.srec.rec.DefaultScreenShot.java

private Window findActiveWindow() {
    Window[] ws = Window.getOwnerlessWindows();
    if (ws.length == 0) {
        return null;
    }/*from ww  w . j  av a 2  s. c om*/
    for (Window w : ws) {
        if (w.isActive()) {
            return w;
        }
    }
    return null;
}