Example usage for javax.swing JFrame setBounds

List of usage examples for javax.swing JFrame setBounds

Introduction

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

Prototype

public void setBounds(int x, int y, int width, int height) 

Source Link

Document

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

Usage

From source file:MyCanvas.java

public static void main(String[] a) {
    JFrame window = new JFrame();
    window.setBounds(30, 30, 300, 300);
    window.getContentPane().add(new MyCanvas());
    window.setVisible(true);// w  w  w.  jav  a 2 s.  co  m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = aWindow.getContentPane();
    content.setLayout(new FlowLayout(FlowLayout.LEFT));
    content.add(new JButton("www.java2s.com"));
    content.add(new JLabel("www.java2s.com"));
    content.add(new JTextField("www.java2s.com"));
    aWindow.setVisible(true);//from  w w w .j  a  v a 2s.c  o  m
}

From source file:MyComponent.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(30, 30, 300, 300); // Size
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MyComponent com = new MyComponent();

    aWindow.add(com);/*from  w w  w .  j  av a  2s  .c om*/

    aWindow.setVisible(true); // Display the window
}

From source file:TryCardLayout.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(30, 30, 300, 300);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.getContentPane().add(new TryCardLayout());
    aWindow.setVisible(true);//from  w  w  w.  j  a  v a  2  s .c o  m
}

From source file:SimplestFrame.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame("This is the Window Title");
    aWindow.setBounds(50, 100, 300, 300);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setVisible(true);/*from w w w .  j a v  a2  s.  c  om*/
}

From source file:Main.java

public static void main(String[] a) {
    JFrame window = new JFrame();
    window.setBounds(30, 30, 300, 300);
    window.getContentPane().add(new Main());
    window.setVisible(true);//from ww w  . j a  va  2  s.  com
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = aWindow.getContentPane();
    content.add(new MouseMotionAnonymous());
    aWindow.setVisible(true);/*  w w  w . jav  a 2s  .co  m*/
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = aWindow.getContentPane();
    content.add(new CardLayoutPanel());
    aWindow.setVisible(true);/*  w w w .j  ava 2 s.c  o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    try {//from   www . jav  a2 s  .  com
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
        System.err.println("Look and feel not set.");
    }
    JFrame aWindow = new JFrame("This is the Window Title");
    aWindow.setBounds(50, 100, 300, 300);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setVisible(true);
}

From source file:ChangeLookFeelToMotifLookAndFeel.java

public static void main(String[] args) {
    try {/*from  ww w. j a  v  a  2 s .  co m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    } catch (Exception e) {
        System.err.println("Look and feel not set.");
    }
    JFrame aWindow = new JFrame("This is the Window Title");
    aWindow.setBounds(50, 100, 300, 300);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setVisible(true);
}