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

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTabbedPane jtp = new JTabbedPane();
    jtp.addTab("Main1", createPanel());
    jtp.addTab("Main2", createPanel());
    f.add(jtp);//from ww  w  .  j  a v  a 2  s .  co  m
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");
    String f = fileChooser.getDialogTitle();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);//from   www .j  av a 2  s.  co  m
}

From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_ON.java

public static void main(String[] args) {
    JFrame frame = new JFrame("LCD Text Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(630, 460));
    frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    frame.pack();
    frame.setVisible(true);/*from  ww  w  .jav a 2s  .c  om*/
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");
    boolean f = fileChooser.getDragEnabled();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);//from   ww w .  j a  va2s.  co m
}

From source file:QandE.ComponentDisplayer.java

public static void main(String[] args) {
    JFrame f = new JFrame("ComponentDisplayer");

    JPanel p = new JPanel(new BorderLayout());
    p.add(new XMarksTheSpot(), BorderLayout.CENTER);

    f.setContentPane(p);/*w w  w.  j  a v  a2 s.  c o m*/
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String s[]) {
    Main example = new Main();
    example.pane = new JTextPane();
    example.pane.setPreferredSize(new Dimension(250, 250));
    example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED));

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(example.menuBar);//from  w  ww .jav  a2  s .  c o m
    frame.getContentPane().add(example.pane, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}

From source file:TextQualityDemo.java

public static void main(String[] args) {
    JFrame frame = new JFrame("LCD Text Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(630, 460));
    frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF));
    frame.pack();
    frame.setVisible(true);//from   w  w  w  .j  a  v  a2  s . c om
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");

    FileFilter f = fileChooser.getFileFilter();
    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);//from   w  w  w.ja  v a 2s  . c o m
}

From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_GASP.java

public static void main(String[] args) {
    JFrame frame = new JFrame("LCD Text Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(630, 460));
    frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_GASP));
    frame.pack();
    frame.setVisible(true);/*from   w  w  w  .ja va  2s.c o m*/
}

From source file:Main.java

public static void main(String[] args) {

    JRadioButton button1 = new JRadioButton("Red");
    JRadioButton button2 = new JRadioButton("Green");
    JRadioButton button3 = new JRadioButton("Blue");
    ButtonGroup colorButtonGroup = new ButtonGroup();
    colorButtonGroup.add(button1);//from   w  ww.  j  a  v a  2  s.co  m
    colorButtonGroup.add(button2);
    colorButtonGroup.add(button3);

    JFrame frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new JLabel("Color:"));
    frame.add(button1);
    frame.add(button2);
    frame.add(button3);
    frame.pack();
    frame.setVisible(true);
}