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[] argv) throws Exception {
    Icon leafIcon = new ImageIcon("leaf.gif");
    Icon openIcon = new ImageIcon("open.gif");
    Icon closedIcon = new ImageIcon("closed.gif");

    JTree tree = new JTree();
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setLeafIcon(leafIcon);/*from   w  w w . j  av a2 s  .co m*/
    renderer.setClosedIcon(closedIcon);
    renderer.setOpenIcon(openIcon);

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

}

From source file:Main.java

public static void main(String avg[]) throws Exception {
    BufferedImage img = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));
    ImageIcon icon = new ImageIcon(img);
    JFrame frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setSize(200, 300);
    JLabel lbl = new JLabel();
    lbl.setIcon(icon);/*from  w w w.  j  a va 2s.c  om*/
    frame.add(lbl);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(200, 200);
    frame.setVisible(true);//from  w  ww  . j a v a 2 s.  c om

    JOptionPane.showMessageDialog(frame, "A");
    JOptionPane.showMessageDialog(frame, "B", "message", JOptionPane.WARNING_MESSAGE);

    int result = JOptionPane.showConfirmDialog(null, "Remove now?");
    switch (result) {
    case JOptionPane.YES_OPTION:
        System.out.println("Yes");
        break;
    case JOptionPane.NO_OPTION:
        System.out.println("No");
        break;
    case JOptionPane.CANCEL_OPTION:
        System.out.println("Cancel");
        break;
    case JOptionPane.CLOSED_OPTION:
        System.out.println("Closed");
        break;
    }

    String name = JOptionPane.showInputDialog(null, "Please enter your name.");
    System.out.println(name);

    JTextField userField = new JTextField();
    JPasswordField passField = new JPasswordField();
    String message = "Please enter your user name and password.";
    result = JOptionPane.showOptionDialog(frame, new Object[] { message, userField, passField }, "Login",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (result == JOptionPane.OK_OPTION)
        System.out.println(userField.getText() + " " + new String(passField.getPassword()));

}

From source file:Center.java

License:asdf

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.add(new Center());
    f.setSize(300, 300);
    f.setVisible(true);//  ww w . ja v a  2s. co  m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    MyComponent component = new MyComponent();
    JFrame f = new JFrame();

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

}

From source file:InsertAction.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);
    InsertAction insertSpaceAction = new InsertAction();
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("pressed SPACE"),
            insertSpaceAction.getValue(Action.NAME));

    component.getActionMap().put(insertSpaceAction.getValue(Action.NAME), insertSpaceAction);

    JFrame f = new JFrame();
    f.add(component);/*w  w w  .j av  a2  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.getContentPane().setBackground(Color.PINK);
    frame.setSize(200, 200);
    frame.setVisible(true);/*from w ww . ja  v a  2s  . c o  m*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

From source file:DrawSimpleText.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new DrawSimpleText());
    f.setSize(300, 200);
    f.setVisible(true);//w  ww .ja v  a  2s.c o m
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("A default label");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);/*from   w  ww.  jav a 2  s . c om*/
    f.add(label);

    f.setVisible(true);
}

From source file:metrics.java

License:asdf

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new metrics());
    f.setSize(300, 300);
    f.setVisible(true);/*from w  ww.j a v  a  2 s  .c o  m*/
}