Example usage for javax.swing JWindow setVisible

List of usage examples for javax.swing JWindow setVisible

Introduction

In this page you can find the example usage for javax.swing JWindow setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:MainClass.java

public static void main(String[] args) {
    JWindow w = new JWindow();
    w.setSize(300, 300);/*from   w  w  w . j av a  2 s . c om*/
    w.setLocation(500, 100);

    w.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame("The Frame");
    f.setSize(300, 300);//from   w  ww  . jav a2s.  c om
    f.setLocation(100, 100);

    JWindow w = new JWindow();
    w.setSize(300, 300);
    w.setLocation(500, 100);

    f.setVisible(true);
    w.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JWindow window = new JWindow();
    window.getContentPane().add(new JLabel("Loading", SwingConstants.CENTER));
    window.setBounds(500, 150, 300, 200);
    window.setVisible(true);
    try {//from   ww  w .  j a  va 2 s. c  o m
        Thread.sleep(5000);
    } catch (InterruptedException e) {
    }
    window.setVisible(false);
    JFrame frame = new JFrame();
    frame.add(new JLabel("Welcome Swing application..."));
    frame.setVisible(true);
    frame.setSize(300, 200);
    window.dispose();
}

From source file:SimpleSplashScreen.java

public static void main(String[] arg) {
    JWindow jwin = new JWindow();
    jwin.getContentPane().add(new JLabel("Loading ZIP/JAR Manager...", SwingConstants.CENTER));
    jwin.setBounds(200, 200, 200, 100);/* w  w  w  .  j a v a  2s  .co  m*/
    jwin.setVisible(true);

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    jwin.setVisible(false);
    jwin.dispose();

}

From source file:Main.java

public static void main(String s[]) {
    JWindow win = new JWindow();

    JPanel pan = new JPanel();
    win.add(pan, "Center");

    pan.setLayout(new FlowLayout());
    pan.add(new JButton("Hello"));

    win.setSize(200, 200);//ww  w  . ja v  a2  s .  c o  m
    win.setVisible(true);
}

From source file:Main.java

public static void main(String[] arg) throws Exception {
    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    Robot robot = new Robot();

    BufferedImage image = robot//from   www .  j  av a2  s .  c  o m
            .createScreenCapture(new Rectangle(0, 0, (int) screenDim.getWidth(), (int) screenDim.getHeight()));

    JWindow window = new JWindow(new JFrame());
    window.getContentPane().setLayout(new BorderLayout());
    window.getContentPane().add(BorderLayout.CENTER, new JLabel(new ImageIcon(image)));
    window.pack();
    window.setVisible(true);
}

From source file:Main.java

License:asdf

public static void main(String[] argv) throws Exception {
    JWindow window = new JWindow();

    JButton component = new JButton("asdf");
    // Add component to the window
    window.getContentPane().add(component, BorderLayout.CENTER);

    // Set initial size
    window.setSize(300, 300);/*from w  w w.j a v a2  s .c o  m*/

    // Show the window
    window.setVisible(true);

}

From source file:com.totsp.sotu.app.ScreenAreaWatcher.java

public void stop() {
    timer.cancel();//from  w  ww .  ja v  a 2 s .  co  m

    for (JWindow w : windows) {
        w.setVisible(false);
    }

    PropertyChangeListener[] listeners = changes.getPropertyChangeListeners();

    for (PropertyChangeListener l : listeners) {
        changes.removePropertyChangeListener(l);
    }
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Displays Splash Screen//from ww w .  j av  a  2 s  . c o m
 * 
 * @return Splash Screen Reference
 */
public static JWindow showSplash() {

    JWindow splash = new JWindow();
    splash.setSize(400, 250);
    splash.setLayout(null);

    JLabel status = new JLabel("Developed by Yohan Liyanage, 2008");
    JLabelAppender.setLabel(status);
    status.setFont(new Font("sansserif", Font.PLAIN, 10));
    status.setSize(350, 30);
    status.setLocation(10, 220);
    splash.add(status);

    JLabel lbl = new JLabel(
            new ImageIcon(ClassLoader.getSystemResource("META-INF/resources/nebula-startup.png")));
    lbl.setSize(400, 250);
    lbl.setLocation(0, 0);
    splash.add(lbl);

    splash.setVisible(true);
    splash.setLocationRelativeTo(null);

    return splash;
}

From source file:com.totsp.sotu.app.ScreenAreaWatcher.java

/** Creates a new instance of ScreenWatcher */
public ScreenAreaWatcher(final Configuration config) throws AWTException {
    super();//from  ww  w .  ja v  a  2  s.c  o m
    this.config = config;
    System.out.println(config.getWidth() + "x" + config.getHeight());
    JPanel jp = null;

    JWindow top = new JWindow();
    top.setBackground(GREEN);
    top.setLocation(0, 0);
    top.setAlwaysOnTop(true);
    jp = new JPanel();
    jp.setBackground(GREEN);
    top.add(jp);
    top.pack();
    top.setSize(config.getWidth(), config.getBorderSize());

    JWindow bottom = new JWindow();
    bottom.setBackground(GREEN);
    bottom.setLocation(0, config.getHeight() - config.getBorderSize());
    bottom.setAlwaysOnTop(true);
    jp = new JPanel();
    jp.setBackground(GREEN);
    bottom.add(jp);
    bottom.pack();
    bottom.setSize(config.getWidth(), config.getBorderSize());

    JWindow left = new JWindow();
    left.setBackground(GREEN);
    left.setLocation(0, 0);
    left.setAlwaysOnTop(true);
    jp = new JPanel();
    jp.setBackground(GREEN);
    left.add(jp);
    left.pack();
    left.setSize(config.getBorderSize(), config.getHeight());

    JWindow right = new JWindow();
    right.setLocation(config.getWidth() - config.getBorderSize(), 0);
    right.setAlwaysOnTop(true);
    jp = new JPanel();
    jp.setBackground(GREEN);
    right.add(jp);
    right.pack();
    right.setSize(config.getBorderSize(), config.getHeight());

    top.setVisible(true);
    bottom.setVisible(true);
    left.setVisible(true);
    right.setVisible(true);

    windows = new JWindow[4];
    windows[0] = top;
    windows[1] = bottom;
    windows[2] = left;
    windows[3] = right;

    MouseInputAdapter adapter = new Adapter(windows);

    top.addMouseListener(adapter);
    top.addMouseMotionListener(adapter);
    bottom.addMouseListener(adapter);
    bottom.addMouseMotionListener(adapter);
    left.addMouseListener(adapter);
    left.addMouseMotionListener(adapter);
    right.addMouseListener(adapter);
    right.addMouseMotionListener(adapter);

    timer.schedule(new ImageUpdateTimerTask(this), 0, config.getMaxUpdateInterval());

    this.addPropertyChangeListener("image", new PropertyChangeListener() {
        HttpClient client = new HttpClient();

        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            BufferedImage img = (BufferedImage) propertyChangeEvent.getNewValue();
            try {
                File outputFile = File.createTempFile("save-" + System.currentTimeMillis(), ".png");
                JAI.create("filestore", img, outputFile.getCanonicalPath(), "PNG", null);
                System.out.println("Temp File:  " + outputFile.getCanonicalPath());
                MultipartPostMethod method = new MultipartPostMethod(
                        config.getServerUrl() + "/ImagePublishingServlet");
                method.addParameter("adminPassword", config.getAdminPassword());
                method.addParameter("conversation", config.getConversationName());
                method.addParameter("image", outputFile);
                client.executeMethod(method);

            } catch (Exception e) {
                System.err.println("Error handling image");
                e.printStackTrace();
            }
        }

    });
}