Example usage for java.awt Frame getFrames

List of usage examples for java.awt Frame getFrames

Introduction

In this page you can find the example usage for java.awt Frame getFrames.

Prototype

public static Frame[] getFrames() 

Source Link

Document

Returns an array of all Frame s created by this application.

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");

    System.out.println("FRAME WINDOWS");
    Frame[] frames = Frame.getFrames();
    for (Frame frame : frames)
        System.out.println(frame.getName() + ": " + frame.getClass());

}

From source file:org.eclipse.swt.snippets.Snippet337.java

public static void main(String args[]) {
    display = new Display();
    EventQueue.invokeLater(() -> {
        JFrame mainFrame = new JFrame("Main Window");
        mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        mainFrame.addWindowListener(new Snippet337.CloseListener());
        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new FlowLayout());
        JButton launchBrowserButton = new JButton("Launch Browser");
        launchBrowserButton.addActionListener(e -> {
            JFrame childFrame = new JFrame();
            final Canvas canvas = new Canvas();
            childFrame.setSize(850, 650);
            childFrame.getContentPane().add(canvas);
            childFrame.setVisible(true);
            display.asyncExec(() -> {
                Shell shell = SWT_AWT.new_Shell(display, canvas);
                shell.setSize(800, 600);
                Browser browser = new Browser(shell, SWT.NONE);
                browser.setLayoutData(new GridData(GridData.FILL_BOTH));
                browser.setSize(800, 600);
                browser.setUrl("http://www.eclipse.org");
                shell.open();/*from  w w  w. j  a v  a  2s.  co m*/
            });
        });

        mainPanel.add(new JTextField("a JTextField"));
        mainPanel.add(launchBrowserButton);
        mainFrame.getContentPane().add(mainPanel, BorderLayout.CENTER);
        mainFrame.pack();
        mainFrame.setVisible(true);
    });
    display.addListener(SWT.Close, event -> EventQueue.invokeLater(() -> {
        Frame[] frames = Frame.getFrames();
        for (int i = 0; i < frames.length; i++) {
            frames[i].dispose();
        }
    }));
    while (!display.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}

From source file:Main.java

public static void main() {

    Frame[] frames = Frame.getFrames();

    for (int i = 0; i < frames.length; i++) {
        String title = frames[i].getTitle();
        System.out.println(title);
        boolean isVisible = frames[i].isVisible();
        System.out.println(isVisible);
    }// www  . j  a  v  a 2  s .c  om
}

From source file:Main.java

public static Frame getActiveFrame() {
    for (Frame frame : Frame.getFrames()) {
        if (frame.isActive()) {
            return frame;
        }/*from  w  ww .  j a  va 2 s . co m*/
    }
    return null;
}

From source file:Main.java

/**
 * Finds frames with an icon: Frames of {@code Frame#getFrames()} where
 * {@code Frame#getIconImage()} returns not null.
 *
 * @return frames with an icon or an empty list
 *//*from w  w  w. j  a  v  a 2 s.  co  m*/
public static List<Frame> findFramesWithIcons() {
    List<Frame> frames = new ArrayList<>();
    Frame[] allFrames = Frame.getFrames();

    for (Frame frame : allFrames) {
        if (frame.getIconImage() != null) {
            frames.add(frame);
        }
    }

    return frames;
}

From source file:Main.java

public static Frame tryFindSuitableFrameOwner() {
    Frame owner = null;/*from   w w  w  . jav  a 2 s. c o m*/
    // find a suitable owner, if any
    Frame[] allFrames = Frame.getFrames();
    if (allFrames != null) {
        for (Frame frame : allFrames) {
            if (frame == null)
                continue;
            if (!frame.isShowing())
                continue;
            if (!frame.isActive())
                continue;
            owner = frame;
            break;
        }
    }
    return owner;
}

From source file:Main.java

public static Frame getFrame(String frameName) {
    Frame[] frames = Frame.getFrames();
    for (Frame frame : frames) {
        if (frame.getName().equals(frameName))
            return frame;
    }/*from  ww w.  jav a  2s .  co  m*/
    return null;
}

From source file:GuiUtil.java

public static void setWaitCursor(boolean yesno) {
    Frame.getFrames()[0].setCursor(yesno ? waitCursor : defCursor);
}

From source file:GUITasks.java

public static Frame getTopFrame() {
    Frame[] frames = Frame.getFrames();
    for (int i = 0; i < frames.length; i++) {
        if (frames[i].getFocusOwner() != null) {
            return frames[i];
        }/* w  ww . j  a v a 2s.c  o m*/
    }
    if (frames.length > 0) {
        return frames[0];
    }
    return null;
}

From source file:Main.java

/**
 * Updates the componentTreeUI of all top-level windows of the 
 * current application./*from   w  ww  .  j  a v a 2s .c o m*/
 * 
 */
public static void updateAllComponentTreeUIs() {
    for (Frame frame : Frame.getFrames()) {
        updateAllComponentTreeUIs(frame);
    }

}