Example usage for java.awt Window add

List of usage examples for java.awt Window add

Introduction

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

Prototype

public Component add(String name, Component comp) 

Source Link

Document

Adds the specified component to this container.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    Button btn = new Button("OK");
    btn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            gs.setFullScreenWindow(null);
        }/*from  w w  w . j  a  va2  s .  com*/
    });
    Frame frame = new Frame(gs.getDefaultConfiguration());
    Window win = new Window(frame);
    win.add(btn, BorderLayout.CENTER);
    try {
        gs.setFullScreenWindow(win);
        win.validate();
    } finally {
        gs.setFullScreenWindow(null);
    }
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.EvolutionMonitor.java

/**
 * Helper method for showing the evolution monitor in a frame or dialog.
 * @param newWindow The frame or dialog used to show the evolution monitor.
 *//*from w  w  w. j  a  v a 2 s  . c om*/
private void showWindow(Window newWindow) {
    if (window != null) {
        window.remove(getGUIComponent());
        window.setVisible(false);
        window.dispose();
        window = null;
    }
    newWindow.add(getGUIComponent(), BorderLayout.CENTER);
    newWindow.pack();
    newWindow.setVisible(true);
    this.window = newWindow;
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void setVisible(boolean b) {
    if (b) {// w ww  . ja  v  a 2s  .  co  m
        if (offi == null && window.clss != InputOnly) {
            allocImage();
        }
        if (window != window.screen.root && !isVisible()) {
            exposed.setBounds(0, 0, 0, 0);
        }
        super.setVisible(true);
        if (window.screen.windowmode != WeirdX.InBrowser && window.hasFrame()) {
            java.awt.Window frame = window.getFrame();

            if (frame instanceof java.awt.Frame) {
                frame.add("Center", this);
                frame.pack();
                synchronized (XWindow.LOCK) {
                    Property p = window.getProperty();
                    while (p != null) {
                        if (p.propertyName == 39)
                            break;
                        p = p.next;
                    }
                    if (p != null && p.type == 31) {
                        String title = "";
                        if (p.size > 0) {
                            title = new String(p.data);
                        }
                        ((java.awt.Frame) (frame)).setTitle(title);
                    }
                }
            } else {
                frame.add(this);
            }

            frame.validate();
            Insets insets = frame.getInsets();
            frame.setSize(window.width + window.borderWidth * 2 + insets.left + insets.right,
                    window.height + window.borderWidth * 2 + insets.top + insets.bottom);
            super.setLocation(insets.left, insets.top);
            frame.validate();
        }
    } else {
        if (isVisible()) {
            super.setVisible(false);
            if (window != window.screen.root && window.screen.root.width * window.screen.root.height
                    / 4 <= window.width * window.height) {
                freeImage();
                exposed.setBounds(0, 0, 0, 0);
            }
        }
    }
}