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(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:Main.java

public static void main(String[] args) {
    JFrame frame = new Main();
    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);/*ww w.  j a  v a 2  s.  com*/
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:Main.java

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

    Container contentPane = frame.getContentPane();
    contentPane.add(new Main());

    frame.setVisible(true);//from  www .  j  a  v a  2s.c  o  m
}

From source file:MyButton.java

public static void main(String[] args) {
    MyButton close = new MyButton("Close");
    JFrame f = new JFrame();
    f.add(close);//from   w ww.  j  a  va2 s .  c  om

    f.setSize(300, 200);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);
    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    Vector data = model.getDataVector();
    Vector row = (Vector) data.elementAt(1);

    int mColIndex = 0;
    List colData = new ArrayList(table.getRowCount());
    for (int i = 0; i < table.getRowCount(); i++) {
        row = (Vector) data.elementAt(i);
        colData.add(row.get(mColIndex));
    }//from   w w  w  .  ja  v  a  2  s  .  c o m

    // Append a new column with copied data
    model.addColumn("Col3", colData.toArray());

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:SVGCanvasDemo.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSVGCanvas Demo");
    frame.setSize(400, 400);

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            System.exit(0);/*  w  w w. j  a v  a 2  s .  c om*/
        }
    });

    new SVGCanvasDemo(frame);
}

From source file:Main.java

public static void main(String[] argv) {
    DefaultTableModel model = new DefaultTableModel() {
        public Class getColumnClass(int columnIndex) {
            Object o = getValueAt(0, columnIndex);
            if (o == null) {
                return Object.class;
            } else {
                return o.getClass();
            }//from  ww w .j a  v  a  2 s  . com
        }
    };
    JTable table = new JTable(model);

    model.addColumn("Boolean", new Object[] { Boolean.TRUE });
    model.addColumn("Date", new Object[] { new Date() });
    model.addColumn("Double", new Object[] { new Double(Math.PI) });
    model.addColumn("Float", new Object[] { new Float(1.2) });
    model.addColumn("Icon", new Object[] { new ImageIcon("icon.gif") });
    model.addColumn("Number", new Object[] { new Integer(1) });
    model.addColumn("Object", new Object[] { "object" });

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextField component = new JTextField();
    component.addFocusListener(new MyFocusListener());
    JFrame f = new JFrame();

    f.add(component);//w  ww .  j  av  a  2  s  . c o  m
    f.setSize(300, 300);
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(800, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setBackground(Color.RED);
    frame.getContentPane().add(new Main());
    frame.setVisible(true);//w ww .  j  a v  a 2 s  .c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextField component = new JTextField();
    component.addMouseMotionListener(new MyMouseMotionListener());
    JFrame f = new JFrame();

    f.add(component);// w  w  w.  j  av a  2 s  .  com
    f.setSize(300, 300);
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(300, 200);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new Main());
    frame.setVisible(true);/*w w  w  . ja va  2  s .c o m*/
}