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) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setDisabledIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);/*  www. ja v  a2s  .  c o m*/
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setDisabledSelectedIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);/*from   w ww . j  av  a2  s . c  o m*/
    f.pack();
    f.setVisible(true);
}

From source file:TextLayoutDemo.java

public static void main(String[] args) {
    JFrame frame = new TextLayoutDemo();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);// w  w w.  j  ava2 s  .c  o m
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setRolloverEnabled(true);/*from   w  w  w.  j  a v a  2 s  . co m*/
    jb.setRolloverIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");
    jb.setIcon(new MyIcon());
    jb.setIconTextGap(50);/*  www  .j  a va  2s  .  com*/

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setPressedIcon(new MyIcon());
    System.out.println(jb.getPressedIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);//from www  .  ja va2  s .  c o m
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setHorizontalTextPosition(20);/*from  w  ww  .jav  a  2s.c  o  m*/
    jb.setIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setHorizontalAlignment(SwingConstants.RIGHT);
    jb.setIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);//from w ww.  j a  v  a2 s  .  c  om
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new Main());
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.setVisible(true);/*from ww  w .j a  va 2 s  . c o  m*/

}