Example usage for javax.swing JFrame pack

List of usage examples for javax.swing JFrame pack

Introduction

In this page you can find the example usage for javax.swing JFrame pack.

Prototype

@SuppressWarnings("deprecation")
public void pack() 

Source Link

Document

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

Usage

From source file:GradientPaintDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   w  w w  . jav  a 2  s  .  c  o  m
        }
    });
    GradientPaintDemo p = new GradientPaintDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:Main.java

public static void main(String[] argv) {
    JFrame frame = new JFrame();
    JButton component1 = new JButton("1");
    JButton component2 = new JButton("2");
    JButton component3 = new JButton("3");

    frame.setLayout(new FlowLayout());
    frame.add(component1);/*from ww  w. j a  v  a  2s  . c  om*/
    frame.add(component2);
    frame.add(component3);

    frame.pack();
    frame.setVisible(true);

    System.out.println(findPrevFocus().getName());
}

From source file:DashedStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//w  w  w .j  a  v  a  2  s .c  om
        }
    });
    DashedStrokeDemo p = new DashedStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:Main.java

public static void main(String[] argv) {
    JFrame frame = new JFrame();
    JButton component1 = new JButton("1");
    JButton component2 = new JButton("2");
    JButton component3 = new JButton("3");

    frame.setLayout(new FlowLayout());
    frame.add(component1);//from w w w  . j a va2 s .  c o m
    frame.add(component2);
    frame.add(component3);

    frame.pack();
    frame.setVisible(true);

    System.out.println(findNextFocus().getName());
}

From source file:TransformDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*  w  w w .j  a  v  a 2s  . c o m*/
        }
    });
    TransformDemo p = new TransformDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("FocusEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JComponent newContentPane = new Main();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setVisible(true);//w  w w .j av  a  2  s . c o m

}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java

public static void main(String args[]) {
    PriceChart chart = new PriceChart();
    //chart.test();

    chart.addSecurity("Stock");
    chart.addPoint("Stock", 10, 10);
    chart.addPoint("Stock", 20, 20);
    chart.addPoint("Stock", 30, 30);

    float[][] points = new float[5][2];
    points[0][0] = 2;// w  w w .  j  a  va 2  s.  c  o m
    points[0][1] = 2;
    points[1][0] = 3;
    points[1][1] = 3;
    points[2][0] = 4;
    points[2][1] = 4;
    points[3][0] = 5;
    points[3][1] = 5;
    points[4][0] = 6;
    points[4][1] = 6;

    chart.addSecurity("Bonds", points);

    JFrame frame = new JFrame();
    frame.getContentPane().add(chart.getChartPanel());
    frame.setVisible(true);
    frame.pack();
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTable t = new JTable(10, 1);
    frame.add(new JScrollPane(t));

    t.getSelectionModel().clearSelection();
    t.getSelectionModel().addSelectionInterval(5, 6);
    t.getSelectionModel().addSelectionInterval(8, 8);
    frame.pack();
    frame.setVisible(true);/*from   ww w . java  2s .  c o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Main newContentPane = new Main();
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setVisible(true);/*from  www .j  av  a  2 s .  c  om*/
}

From source file:TexturePaintDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from   w w  w.  j a v a2  s .  c  o  m*/
        }
    });
    TexturePaintDemo p = new TexturePaintDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}