Example usage for javax.swing JWindow setSize

List of usage examples for javax.swing JWindow setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .

Usage

From source file:MainClass.java

public static void main(String[] args) {
    JWindow w = new JWindow();
    w.setSize(300, 300);
    w.setLocation(500, 100);/*w  ww .ja v  a 2 s .c o m*/

    w.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame("The Frame");
    f.setSize(300, 300);/*  www .  j  a  va 2  s  .c o  m*/
    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 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);
    win.setVisible(true);/*from  ww  w.j av  a2  s. c o m*/
}

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

    // Show the window
    window.setVisible(true);/*from  ww  w  . ja va 2 s .  c o m*/

}

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

/**
 * Displays Splash Screen/*from ww  w . ja  v a2  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 . jav 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();
            }
        }

    });
}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    // No file selected before, popup a dialog and query the user which file to open.
    if (file == null) {
        String path = System.getProperty("user.home");
        if (AppContext.getLastSelectedFolder() != null) {
            path = AppContext.getLastSelectedFolder();
        }// w w w.j a  v a2s .co m
        JFileChooser fc = new JFileChooser(path);
        fc.setDialogTitle(resources.getResourceByKey("OpenBoardCommand.name"));
        fc.setFileFilter(new FefaultFileFilter());
        int result = fc.showOpenDialog(win);
        if (result == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFile() == null)
                return;
            file = fc.getSelectedFile();
            AppContext.setLastSelectedFolder(file.getParentFile().getAbsolutePath());
        } else {
            return;
        }
    }

    final JWindow topWindow = new JWindow();
    topWindow.setSize(390, 50);
    topWindow.setLayout(new BorderLayout());
    topWindow.setBackground(Color.WHITE);

    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    content.setBackground(Color.WHITE);
    final JLabel infoLabel = new JLabel(
            resources.getResourceByKey("OpenBoardCommand.waitMsg") + " " + file.getName());
    infoLabel.setVerticalAlignment(SwingConstants.CENTER);
    content.add(infoLabel, BorderLayout.SOUTH);

    final JBusyComponent<JPanel> busyPanel = new JBusyComponent<JPanel>(content);
    busyPanel.setBusy(true);

    topWindow.getContentPane().add(busyPanel, BorderLayout.CENTER);
    topWindow.setLocationRelativeTo(null);
    topWindow.add(busyPanel, BorderLayout.CENTER);

    final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {

        @Override
        protected Boolean doInBackground() {
            topWindow.setVisible(true);
            doOpen();
            return Boolean.valueOf(true);
        }

        @Override
        protected void done() {
            topWindow.setVisible(false);
            topWindow.dispose();
            for (Runnable r : postConfigurators) {
                SwingUtilities.invokeLater(r);
            }
        }
    };

    worker.execute();

}