Example usage for java.awt Container add

List of usage examples for java.awt Container add

Introduction

In this page you can find the example usage for java.awt Container add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

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

/**
 * a driver for this demo/*from w  ww . j a  v a  2  s .  co  m*/
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new LensVertexImageShaperDemo());
    frame.pack();
    frame.setVisible(true);
}

From source file:TreeColapse.java

/**
 * a driver for this demo// w  ww. j  a va2 s  . c  o  m
 * 
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new TreeColapse());
    frame.pack();
    frame.setVisible(true);
}

From source file:gridvisual.GridVisualize.java

/**
 * a driver for this demo/*from w w w  . java2  s.  c  om*/
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new GridVisualize());
    frame.pack();
    frame.setVisible(true);
}

From source file:com.schnee.tweetgeister.visualization.TweetgeisterBalloonLayout.java

/**
 * a driver for this demo/*ww  w .j  a va 2  s.c  o m*/
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new TweetgeisterBalloonLayout());
    frame.pack();
    frame.setVisible(true);
}

From source file:GlueSample.java

public static void main(String args[]) {
    Box horizontalBox;// w ww.ja v a 2 s.co m
    JPanel panel;
    JFrame frame = new JFrame("Horizontal Glue");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(Box.createGlue());
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(new JButton("Right"));
    panel = new JPanel(new BorderLayout());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("Beginning Glue"));
    contentPane.add(panel);

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(Box.createGlue());
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(Box.createGlue());
    horizontalBox.add(new JButton("Right"));
    panel = new JPanel(new BorderLayout());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("2 Middle Glues"));
    contentPane.add(panel);

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(Box.createGlue());
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(new JButton("Right"));
    horizontalBox.add(Box.createGlue());
    panel = new JPanel(new BorderLayout());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("Beginning/End Glues"));
    contentPane.add(panel);

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(new JButton("Right"));
    panel = new JPanel(new BorderLayout());
    horizontalBox.add(Box.createGlue());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("End Glue"));
    contentPane.add(panel);

    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:StrutSample.java

public static void main(String args[]) {
    Box horizontalBox;/* ww w  .j  a v  a 2  s  .  com*/
    JPanel panel;
    JFrame frame = new JFrame("Horizontal Strut");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(Box.createHorizontalStrut(10));
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(new JButton("Right"));
    panel = new JPanel(new BorderLayout());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("Beginning Strut"));
    contentPane.add(panel);

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(Box.createHorizontalStrut(10));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(Box.createHorizontalStrut(25));
    horizontalBox.add(new JButton("Right"));
    panel = new JPanel(new BorderLayout());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("2 Middle Struts"));
    contentPane.add(panel);

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(Box.createHorizontalStrut(25));
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(new JButton("Right"));
    horizontalBox.add(Box.createHorizontalStrut(10));
    panel = new JPanel(new BorderLayout());
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("Beginning/End Struts"));
    contentPane.add(panel);

    horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(new JButton("Left"));
    horizontalBox.add(new JButton("Middle"));
    horizontalBox.add(new JButton("Right"));
    panel = new JPanel(new BorderLayout());
    horizontalBox.add(Box.createHorizontalStrut(10));
    panel.add(horizontalBox);
    panel.setBorder(BorderFactory.createTitledBorder("End Strut"));
    contentPane.add(panel);

    frame.setSize(300, 300);
    frame.setVisible(true);
}

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

/**
 * a driver for this demo/* ww w  .ja  v a 2  s.c  o  m*/
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    FacebookGraphApplet applet = new FacebookGraphApplet();
    applet.init();

    content.add(applet);
    frame.pack();
    frame.setVisible(true);
}

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

/**
* a driver for this demo/* www. j a v a  2s .c  o m*/
*/
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new VertexImageShaperDemo());
    frame.pack();
    frame.setVisible(true);
}

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

/**
 * a driver for this demo//from   w  ww . java  2  s .c om
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new PerspectiveVertexImageShaperDemo());
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));

    // Define Start Button
    JButton startButton = new JButton("Start");
    ActionListener startActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component parent = (Component) actionEvent.getSource();
            monitor = new ProgressMonitor(parent, "Loading Progress", "Getting Started...", 0, 200);
            progress = 0;//from   w  ww .j av a 2  s  . co m
        }
    };
    startButton.addActionListener(startActionListener);
    contentPane.add(startButton);

    // Define Manual Increase Button
    // Pressing this button increases progress by 5
    JButton increaseButton = new JButton("Manual Increase");
    ActionListener increaseActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (monitor == null)
                return;
            if (monitor.isCanceled()) {
                System.out.println("Monitor canceled");
            } else {
                progress += 5;
                monitor.setProgress(progress);
                monitor.setNote("Loaded " + progress + " files");
            }
        }
    };
    increaseButton.addActionListener(increaseActionListener);
    contentPane.add(increaseButton);

    // Define Automatic Increase Button
    // Start Timer to increase progress by 3 every 250 ms
    JButton autoIncreaseButton = new JButton("Automatic Increase");
    ActionListener autoIncreaseActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (monitor != null) {
                if (timer == null) {
                    timer = new Timer(250, new ProgressMonitorHandler());
                }
                timer.start();
            }
        }
    };
    autoIncreaseButton.addActionListener(autoIncreaseActionListener);
    contentPane.add(autoIncreaseButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}