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

License:asdf

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("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);//from   www. j a  v  a2s.  c o m
    label.setPreferredSize(new Dimension(150, 100));

    label.setText("Bottom Right");
    label.setHorizontalAlignment(JLabel.RIGHT);
    label.setVerticalAlignment(JLabel.BOTTOM);

    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

License:asdf

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("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);//from w ww .  ja  v a2 s  .c o  m
    label.setPreferredSize(new Dimension(150, 100));

    label.setText("Centered");
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setVerticalAlignment(JLabel.CENTER);

    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame parentFrame = new JFrame();
    parentFrame.setSize(500, 150);
    JLabel jl = new JLabel();
    jl.setText("Count : 0");

    parentFrame.add(BorderLayout.CENTER, jl);
    parentFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    final JDialog dlg = new JDialog(parentFrame, "Progress Dialog", true);
    JProgressBar dpb = new JProgressBar(0, 500);
    dlg.add(BorderLayout.CENTER, dpb);
    dlg.add(BorderLayout.NORTH, new JLabel("Progress..."));
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setSize(300, 75);
    dlg.setLocationRelativeTo(parentFrame);

    Thread t = new Thread(new Runnable() {
        public void run() {
            dlg.setVisible(true);
        }
    });
    t.start();
    for (int i = 0; i <= 500; i++) {
        jl.setText("Count : " + i);
        dpb.setValue(i);
        if (dpb.getValue() == 500) {
            dlg.setVisible(false);
            System.exit(0);

        }
        try {
            Thread.sleep(25);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    dlg.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel(new BorderLayout());
    final JTree tree = new JTree();
    panel.add(new JScrollPane(tree));
    JButton btn = new JButton("Press Me");
    btn.addActionListener(et -> {/* w  ww . j av a2s  .co  m*/
        for (Enumeration e = ((TreeNode) tree.getModel().getRoot()).children(); e.hasMoreElements();) {
            TreeNode tn = (TreeNode) e.nextElement();
            tree.expandPath(new TreePath(((DefaultTreeModel) tree.getModel()).getPathToRoot(tn)));
        }
    });
    panel.add(btn, BorderLayout.SOUTH);
    JFrame frame = new JFrame("");
    frame.getContentPane().add(panel);
    frame.setSize(300, 300);
    frame.setLocation(100, 100);
    frame.pack();
    frame.show();
}

From source file:TextBox3D.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new TextBox3D("Help Me", 200, 200));
    f.setSize(300, 300);
    f.setVisible(true);//from  w  w  w  .  j  a v  a 2s.c  om
}

From source file:PaintingAndStroking.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new PaintingAndStroking());
    f.setSize(350, 250);
    f.show();//  ww w . ja  v a2 s. co  m
}

From source file:FillRectPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("FillRect");
    frame.setSize(300, 200);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w  w  w.ja  v  a  2 s .co m*/
        }
    });
    Container contentPane = frame.getContentPane();
    contentPane.add(new FillRectPanel());

    frame.show();
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("ColorPan");
    frame.getContentPane().add(new Main());
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);/*from w ww.  j a v  a 2s .c om*/
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame aWindow = new MainClass();
    aWindow.setSize(200, 200);
    aWindow.setVisible(true);//from   ww  w  .  j av  a  2s  .  c  o  m
}

From source file:SimpleApp3.java

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

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    new SimpleApp3(frame);
}