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:ShowImage.java

static public void main(String args[]) throws Exception {
    JFrame frame = new JFrame("ShowImage.java");
    Panel panel = new ShowImage(args[0]);
    frame.getContentPane().add(panel);//  w  w  w .  j  ava2s  .  c  o  m
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    String[] items = { "A", "B", "C" };
    JComboBox<String> comboBox1 = new MyComboBox1<>(items);
    JPanel p = new JPanel();
    p.add(comboBox1);//from   w w w.j  a v a  2  s .  c  o  m

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(p);
    f.setSize(320, 240);
    f.setVisible(true);
}

From source file:OvalPanelCanvas.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Oval Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new OvalPanelCanvas());
    frame.setSize(300, 200);
    frame.setVisible(true);/*  w  w w . j ava 2 s.c o  m*/
}

From source file:HeaderlessSample.java

public static void main(String args[]) {
    Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },
            { "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
    Object columnNames[] = { "Column 1", "Column 2", "Column 3" };
    //    JTable table = new HeaderlessTable(rowData, columnNames);
    JTable table = new JTable(rowData, columnNames);
    table.setTableHeader(null);//from   w w w  .  jav a  2 s.co  m
    JScrollPane scrollPane = new JScrollPane(table);
    //    scrollPane.setColumnHeaderView(null);
    JFrame frame = new JFrame("Headerless Table");
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new Main());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(200, 200);
    frame.setVisible(true);// ww w  . ja v  a  2s.c  o  m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Text attributes");
    frame.add(new Main());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(620, 190);
    frame.setLocationRelativeTo(null);//ww  w . j av a 2s . c  o m
    frame.setVisible(true);
}

From source file:TreeRowHeightCache.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    if (tree.getRowHeight() <= 0) {
        tree.setRowHeight(1);/*  ww w. ja va  2 s.  c  om*/
    }
    tree.setRowHeight(0);

    JFrame frame = new JFrame("Image");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setSize(400, 300);
    Polygon p = new Polygon();
    p.addPoint(10, 10);//  w w  w .j  av a2s  .com
    p.addPoint(100, 300);
    p.addPoint(300, 300);
    p.addPoint(10, 10);

    PolygonButton btn = new PolygonButton(p, "button");
    f.getContentPane().add(btn);
    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}

From source file:ResizeRectangle.java

public static void main(String[] args) {

    JFrame frame = new JFrame("Resize Rectangle");

    frame.add(new ResizeRectangle());
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);/*from w w w.j  a  v a  2  s  .c om*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Composition");
    frame.add(new Main());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 120);
    frame.setVisible(true);//from   w w  w. ja  va2s . c om
}