Example usage for javax.swing JFrame setSize

List of usage examples for javax.swing JFrame setSize

Introduction

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

Prototype

public void setSize(Dimension d) 

Source Link

Document

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

Usage

From source file:AreaSubtracting.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", new AreaSubtracting());
    frame.pack();//  w ww.java  2 s .  c o  m
    frame.setSize(new Dimension(400, 300));
    frame.setVisible(true);
}

From source file:AreaExclusiveOr.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", new AreaExclusiveOr());
    frame.pack();//from   w ww  . ja  v  a 2  s .  co  m
    frame.setSize(new Dimension(400, 300));
    frame.setVisible(true);
}

From source file:AreaIntersecting.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", new AreaIntersecting());
    frame.pack();/* w  w w  . j av a 2 s  .  c  o  m*/
    frame.setSize(new Dimension(400, 300));
    frame.setVisible(true);
}

From source file:Capture.java

public static void main(String[] args) {
    JFrame capture = new JFrame();
    capture.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Toolkit kit = Toolkit.getDefaultToolkit();
    final Dimension d = kit.getScreenSize();
    capture.setSize(d);

    Rectangle rect = new Rectangle(d);
    try {// ww w.  j  av a  2 s  . co m
        Robot robot = new Robot();
        final BufferedImage image = robot.createScreenCapture(rect);
        image.flush();
        JPanel panel = new JPanel() {
            public void paintComponent(Graphics g) {
                g.drawImage(image, 0, 0, d.width, d.height, this);
            }
        };
        panel.setOpaque(false);
        panel.prepareImage(image, panel);
        panel.repaint();
        capture.getContentPane().add(panel);
    } catch (Exception e) {
        e.printStackTrace();
    }

    capture.setVisible(true);
}