Example usage for java.awt Window getClass

List of usage examples for java.awt Window getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

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[] windows = Window.getWindows();
    for (Window window : windows)
        System.out.println(window.getName() + ": " + window.getClass());

}

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:Main.java

/**
 * Returns whether specified window is a HeavyWeightWindow or not.
 *
 * @param window// w  w w .j a  v a 2s . com
 *            window to process
 * @return true if specified window is a HeavyWeightWindow, false otherwise
 */
public static boolean isHeavyWeightWindow(final Window window) {
    if (window == null) {
        return false;
    }
    final String can = window.getClass().getCanonicalName();
    return can != null && can.endsWith("HeavyWeightWindow");
}

From source file:Main.java

public static boolean isWindowActive(Window window) {
    if (getJavaVersion() >= 1.4) {
        try {/* w  w  w.  ja  va  2 s . c o  m*/
            Class paramTypes[] = null;
            Object args[] = null;
            Method m = window.getClass().getMethod("isActive", paramTypes);
            Boolean b = (Boolean) m.invoke(window, args);
            return b;
        } catch (Exception ex) {
        }
    }
    return true;
}

From source file:Main.java

public static boolean isWindowActive(Window window) {
    if (getJavaVersion() >= 1.4) {
        try {/*from   w w w .  j a  v  a 2 s  .co  m*/
            Class paramTypes[] = null;
            Object args[] = null;
            Method m = window.getClass().getMethod("isActive", paramTypes);
            Boolean b = (Boolean) m.invoke(window, args);
            return b.booleanValue();
        } catch (Exception ex) {
        }
    }
    return true;
}

From source file:com.moss.appprocs.swing.ProgressDialog.java

private static JDialog makeDialogFor(Component c) {
    Window w = SwingUtilities.windowForComponent(c);
    if (w == null) {
        throw new RuntimeException(
                "The component heirarchy for the passed component does not end at a window:" + c);
    } else if (w instanceof Frame) {
        return new JDialog((Frame) w);
    } else if (w instanceof Dialog) {
        return new JDialog((Dialog) w);
    } else {/*from w  w  w .  j  av  a  2  s.  com*/
        throw new RuntimeException("Unsupported window type:" + w.getClass().getName());
    }
}