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

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

    Container contentPane = frame.getContentPane();
    contentPane.add(new NotHelloWorldPanel());

    frame.show();
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(600, 400);
    frame.setVisible(true);/* w  ww.j  av a  2s  . c  o  m*/
    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> {
        System.out.println(frame.getLocation());
    }, 0, 1000, TimeUnit.MILLISECONDS);
}

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  ww. j  av a2 s . c o  m

    f.setSize(300, 300);

    f.setVisible(true);

}

From source file:XORPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("XOR");
    frame.setSize(300, 200);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  www .  jav a  2s .c o  m*/
        }
    });
    Container contentPane = frame.getContentPane();
    contentPane.add(new XORPanel());

    frame.show();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JComponent com = new DraggableComponent();

    JFrame f = new JFrame();

    f.add(com);/*  w w  w  .  j a  v a  2s  . c  o  m*/
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:XORRectangles.java

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

From source file:Main.java

public static void main(String args[]) {
    JTree tree = new JTree();
    TreeSelectionListener treeSelectionListener = new TreeSelectionListener() {

        @Override//  www .j av  a2 s .  co m
        public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
            JTree treeSource = (JTree) treeSelectionEvent.getSource();
            System.out.println("Min: " + treeSource.getMinSelectionRow());
            System.out.println("Max: " + treeSource.getMaxSelectionRow());
            System.out.println("Lead: " + treeSource.getLeadSelectionRow());
            System.out.println("Row: " + treeSource.getSelectionRows()[0]);
        }
    };
    tree.addTreeSelectionListener(treeSelectionListener);
    JFrame frame = new JFrame();
    frame.add(new JScrollPane(tree));
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Overlap.java

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

From source file:SimplestGradientPaint.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new SimplestGradientPaint());
    f.setSize(350, 250);
    f.show();//ww  w.j  a  va  2 s. co m

}

From source file:DrawRectPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("DrawRect");
    frame.setSize(300, 200);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*w w w .j  a va 2  s. c o  m*/
        }
    });
    Container contentPane = frame.getContentPane();
    contentPane.add(new DrawRectPanel());

    frame.show();
}