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

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new SmoothMove());
    f.setSize(200, 200);
    f.show();/*from w  ww.j av  a  2 s . c  o m*/
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame frame = new JFrame("MainClass");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(225, 150);
    frame.setLocation(200, 200);/*from   w ww.j a  v a  2s  . c  om*/
    frame.setContentPane(new MainClass());
    frame.setVisible(true);
}

From source file:CombiningShapes.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new CombiningShapes());
    f.setSize(220, 220);
    f.setVisible(true);/*  w  ww.j  av  a2 s.  co m*/
}

From source file:GridBag3.java

public static void main(String[] args) {
    JFrame frame = new JFrame("GridBag3");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 200);
    frame.setLocation(200, 200);/* w w  w .  ja v  a 2s  .co  m*/
    frame.setContentPane(new GridBag3());
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextArea comp = new JTextArea();
    String actionName = "Lowercase";

    JFrame f = new JFrame();
    f.add(new JScrollPane(comp));
    f.setSize(300, 300);
    f.setVisible(true);//from ww w.ja  va2s.co m
    comp.getInputMap().put(KeyStroke.getKeyStroke("F2"), actionName);

    comp.getActionMap().put(actionName, new TextAction(actionName) {
        public void actionPerformed(ActionEvent evt) {
            JTextComponent comp = getTextComponent(evt);

            if (comp.getSelectionStart() == comp.getSelectionEnd()) {
                if (comp.getCaretPosition() < comp.getDocument().getLength()) {
                    try {
                        int pos = comp.getCaretPosition();
                        Document doc = comp.getDocument();
                        String str = doc.getText(pos, 1).toLowerCase();

                        doc.remove(pos, 1);
                        doc.insertString(pos, str, null);
                        comp.moveCaretPosition(pos + 1);
                    } catch (Exception e) {
                        System.out.println();
                    }
                }
            } else {
                int s = comp.getSelectionStart();
                int e = comp.getSelectionEnd();

                comp.replaceSelection(comp.getSelectedText().toLowerCase());
                comp.select(s, e);
            }
        }
    });
}

From source file:Main.java

public static void main(String args[]) {
    Main anim = new Main();
    JFrame app = new JFrame("Animator test");
    app.add(anim, BorderLayout.CENTER);
    app.setSize(300, 300);
    app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    app.setSize(anim.getPreferredSize().width + 10, anim.getPreferredSize().height + 30);
}

From source file:Main.java

public static void main(String[] args) {
    String imageFile = "A.jpg";
    RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
    Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile));
    image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_SMOOTH);
    JFrame frame = new JFrame("DragImage");
    frame.getContentPane().add(new Main(image));
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);/*from ww  w  . j ava 2  s.  com*/
}

From source file:Main.java

public static void main(String[] args) {
    String imageFile = "A.jpg";
    RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
    Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile));
    image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_DEFAULT);
    JFrame frame = new JFrame("DragImage");
    frame.getContentPane().add(new Main(image));
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);/*from w  w  w  .  j  av a  2s.  com*/
}

From source file:Main.java

public static void main(String[] args) {
    String imageFile = "A.jpg";
    RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
    Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile));
    image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_FAST);
    JFrame frame = new JFrame("DragImage");
    frame.getContentPane().add(new Main(image));
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);/* ww  w .  j  a v a2s. c o  m*/
}

From source file:GridBag5.java

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

    frame.setSize(250, 250);
    frame.setLocation(200, 200);//  w w w .ja  va 2s. c o m
    frame.setContentPane(new GridBag5());
    frame.setVisible(true);
}