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:RectangleDemo2D.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  a  2  s.co  m
        }
    });
    JApplet applet = new RectangleDemo2D();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:edu.jhuapl.graphs.jfreechart.BarEffectsTest.java

/**
 * @param args//  ww w . j av  a  2  s .  c  om
 */
public static void main(String[] args) throws GraphException {
    JFreeChart chart = getSource().getChart();
    JFrame frame = new JFrame("Graph");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    ChartPanel content = new ChartPanel(chart);
    content.setPreferredSize(new Dimension(800, 500));

    frame.getContentPane().add(content);

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

From source file:com.google.code.facebook.graph.sna.applet.AddNodeDemo.java

public static void main(String[] args) {
    AddNodeDemo and = new AddNodeDemo();
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(and);/* w ww . j  a v a  2 s. co  m*/

    and.init();
    and.start();
    frame.pack();
    frame.setVisible(true);
}

From source file:GradientPaintEllipse.java

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

From source file:example.Example1.java

public static void main(String[] args) {
    Example1 and = new Example1();
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(and);//from   w w w . j  a  v a 2s .  c om

    and.init();
    and.start();
    frame.pack();
    frame.setVisible(true);
}

From source file:LineDemo2D.java

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

From source file:FilledRectangleDemo2D.java

public static void main(String s[]) {
    JFrame f = new JFrame("");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   ww w . j  a  v  a2 s .c  om
        }
    });
    JApplet applet = new FilledRectangleDemo2D();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:GradientPaintDemo2D.java

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

From source file:BorderDemo.java

public static void main(String[] args) {
    JFrame frame = new BorderDemo();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   w  w  w .j  av  a  2 s .c o  m
        }
    });

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

From source file:DashedRectangleDemo2D.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*/
        }
    });
    JApplet applet = new DashedRectangleDemo2D();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}