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 JFrame("DefaultButton");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Icon warnIcon = new ImageIcon("yourFile.gif");
    JButton button2 = new JButton(warnIcon);
    frame.add(button2);/* ww  w .j a  va 2 s  .co  m*/
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel(new GridLayout(10, 10, 10, 10));

    for (int i = 0; i < 100; i++) {
        panel.add(new JButton(String.valueOf(i)));
    }// w ww . j a v a  2  s . c o  m

    frame.add(panel);

    frame.setSize(600, 600);
    frame.setVisible(true);
}

From source file:ScrollableLabel.java

public static void main(String[] args) {
    JFrame f = new JFrame("JScrollPane Demo");

    ImageIcon ii = new ImageIcon("largeJava2sLogo.gif");
    JScrollPane jsp = new JScrollPane(new ScrollableLabel(ii));
    f.getContentPane().add(jsp);//w  w w  .  java2  s  . c o m
    f.setSize(300, 250);
    f.setVisible(true);

}

From source file:Main.java

public static void main(String args[]) throws Exception {
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name: ");
    label.setDisplayedMnemonic(KeyEvent.VK_N);
    JTextField textField = new JTextField();
    label.setLabelFor(textField);//  w ww . j  ava2 s  . c  o  m
    panel.add(label, BorderLayout.WEST);
    panel.add(textField, BorderLayout.CENTER);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel, BorderLayout.NORTH);
    frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH);
    frame.setSize(250, 150);
    frame.setVisible(true);

    textField.setText("your text");
    String filename = "test.txt";

    FileWriter writer = new FileWriter(filename);
    textField.write(writer);
    writer.close();

}

From source file:SparseTableModel.java

public static void main(String[] a) {

    String headers[] = { "A", "B" };
    TableModel model = new SparseTableModel(10, headers);
    JTable table = new JTable(model);
    model.setValueAt("1", 0, 0);
    model.setValueAt("2", 9, 0);
    model.setValueAt("3", 5, 1);
    model.setValueAt("4", 8, 1);

    JFrame frame = new JFrame("Fixed Column Table");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new JScrollPane(table), BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);/*www. j  ava2  s .  c o m*/
}