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 frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel progressBarPanel = new Main();
    frame.add(progressBarPanel);/*from   w  ww . java2s .c om*/

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

From source file:Main.java

public static void main(String[] args) {
    DefaultListModel<String> model = new DefaultListModel<>();
    JList<String> sList = new JList<>(model);
    for (int i = 0; i < 100; i++) {
        model.addElement("String " + i);
    }/*w  w  w  . j  a v a2 s.c o m*/

    sList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    sList.setVisibleRowCount(-1);
    sList.setLayoutOrientation(JList.HORIZONTAL_WRAP);

    JFrame frame = new JFrame("Foo001");
    frame.getContentPane().add(new JScrollPane(sList));
    frame.getContentPane().setPreferredSize(new Dimension(400, 300));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    for (int i = 0; i < tree.getRowCount(); i++) {
        tree.expandRow(i);//from w ww  . j a va 2s .  c  o  m
    }
    f.add(new JScrollPane(tree));
    f.pack();
    f.setSize(200, 200);
    f.setVisible(true);
}

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();
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setVisible(true);/*ww  w .  ja  va 2s  .c om*/

}

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

public static void main(String[] args) throws IOException {
    JFrame jf = new JFrame();
    Graph g = getGraph();/* w ww .j a  v  a 2  s .  c  om*/
    VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
    jf.getContentPane().add(vv);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.pack();
    jf.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComponent newContentPane = new Main();
    newContentPane.setOpaque(true);//from   w  ww .  ja  v a  2 s .c  om
    frame.setContentPane(newContentPane);

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

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    Main mainPanel = new Main(frame);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(mainPanel);
    frame.pack();
    frame.setVisible(true);//  www  . j av a  2s  . c o m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    final JTabbedPane jtp = new JTabbedPane();
    jtp.add("One", createPanel());
    jtp.add("Two", createPanel());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(jtp);//from  w  ww  .  j  a  v  a 2 s  .  c om
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JProgressBar pb = new JProgressBar();
    JTextArea ta = new JTextArea(10, 20);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(new JScrollPane(ta));
    frame.add(pb, BorderLayout.SOUTH);
    frame.pack();
    frame.setVisible(true);/*from   w  w w .  j  a  v  a2  s . c  om*/

    Timer timer = new Timer(250, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            index++;
            if (index >= 100) {
                ((Timer) (e.getSource())).stop();
            }
            ta.append("Line " + index + "\n");
            pb.setValue(index);
        }
    });
    timer.setRepeats(true);
    timer.setCoalesce(true);
    timer.start();
}

From source file:edu.uci.ics.jung.samples.SimpleGraphDraw.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) throws IOException {
    JFrame jf = new JFrame();
    Graph g = getGraph();// w w  w .  java 2  s.c  om
    VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
    jf.getContentPane().add(vv);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.pack();
    jf.setVisible(true);
}