Example usage for java.awt Panel add

List of usage examples for java.awt Panel add

Introduction

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

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:GUIManagerQuery.java

/***************************************************************************
 * Construct the GUIManagerQuery object, constructing the various components
 * and laying them out on the screen./* w w w. ja va 2s  . c  o m*/
 **************************************************************************/
public GUIManagerQuery() {
    super("GUIManagerQuery");
    setLayout(new BorderLayout());

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    versionLabel = new Label("JMF v" + Manager.getVersion());
    add(versionLabel, "North");

    Panel lower = new Panel();
    lower.add(new Label("Content/Protocol"));
    contentsField = new TextField(32);
    lower.add(contentsField);
    add(lower, "South");

    results = new TextArea(20, 80);
    results.setEditable(false);
    add(results, "Center");

    Panel controls = new Panel();
    controls.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    hintsButton = new Button("Hints");
    gbc.gridx = 0;
    gbc.gridy = 0;
    controls.add(hintsButton, gbc);
    hintsButton.addActionListener(this);

    playersButton = new Button("Players");
    gbc.gridy = 1;
    controls.add(playersButton, gbc);
    playersButton.addActionListener(this);

    processorsButton = new Button("Processors");
    gbc.gridy = 2;
    controls.add(processorsButton, gbc);
    processorsButton.addActionListener(this);

    sourcesButton = new Button("DataSources");
    gbc.gridy = 3;
    controls.add(sourcesButton, gbc);
    sourcesButton.addActionListener(this);

    add(controls, "East");
}

From source file:SimpleBillboard.java

public SimpleBillboard() {
    VirtualUniverse myUniverse = new VirtualUniverse();
    Locale myLocale = new Locale(myUniverse);
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));
    myLocale.addBranchGraph(buildContentBranch());
    setTitle("SimpleBillboard");
    setSize(400, 400);/*from   www. j a  va 2  s. com*/
    setLayout(new BorderLayout());
    Panel bottom = new Panel();
    bottom.add(exitButton);
    add(BorderLayout.CENTER, myCanvas3D);
    add(BorderLayout.SOUTH, bottom);
    exitButton.addActionListener(this);
    setVisible(true);
}

From source file:com.seniorproject.augmentedreality.chart.ChartCreator.java

public Panel drawChart() {
    dataset = createDataset();//from w w  w.j  a  v a2s .  c  o  m
    chart = createChart(dataset);
    chartPanel = new ChartPanel(chart);
    //        chartPanel.setPreferredSize(new java.awt.Dimension(640, 480));
    Panel panel = new Panel();
    panel.setSize(640, 480);
    panel.add(chartPanel);
    panel.setVisible(true);
    return panel;
}

From source file:SimpleSwitch.java

public SimpleSwitch() {
    VirtualUniverse myUniverse = new VirtualUniverse();
    Locale myLocale = new Locale(myUniverse);
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));
    myLocale.addBranchGraph(buildContentBranch(buildShape()));
    setTitle("SimpleWorld");
    setSize(400, 400);/*from  ww w  . j av a 2s .  c  o m*/
    setLayout(new BorderLayout());
    Panel bottom = new Panel();
    bottom.add(boxButton);
    bottom.add(coneButton);
    bottom.add(exitButton);
    add(BorderLayout.CENTER, myCanvas3D);
    add(BorderLayout.SOUTH, bottom);
    exitButton.addActionListener(this);
    boxButton.addActionListener(this);
    coneButton.addActionListener(this);
    setVisible(true);
}

From source file:SimpleTransform.java

public SimpleTransform() {
    VirtualUniverse myUniverse = new VirtualUniverse();
    Locale myLocale = new Locale(myUniverse);
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));
    myLocale.addBranchGraph(buildContentBranch(buildShape()));
    setTitle("SimpleWorld");
    setSize(400, 400);//from   ww  w .  j a v a 2s. c  o m
    setLayout(new BorderLayout());
    Panel bottom = new Panel();
    bottom.add(leftButton);
    bottom.add(rightButton);
    bottom.add(exitButton);
    add(BorderLayout.CENTER, myCanvas3D);
    add(BorderLayout.SOUTH, bottom);
    exitButton.addActionListener(this);
    leftButton.addActionListener(this);
    rightButton.addActionListener(this);
    setVisible(true);
}

From source file:ToolbarFrame1.java

public ToolbarFrame1() {
    super("Toolbar Example (AWT)");
    setSize(450, 250);/* w  w w . ja v  a2  s  .c  o  m*/
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    ActionListener printListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            System.out.println(ae.getActionCommand());
        }
    };

    Panel toolbar = new Panel();
    toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));

    cutButton = new Button("Cut");
    cutButton.addActionListener(printListener);
    toolbar.add(cutButton);

    copyButton = new Button("Copy");
    copyButton.addActionListener(printListener);
    toolbar.add(copyButton);

    pasteButton = new Button("Paste");
    pasteButton.addActionListener(printListener);
    toolbar.add(pasteButton);

    add(toolbar, BorderLayout.NORTH);
}

From source file:TimerTest.java

public void init() {
    Panel panel = new Panel();
    String header = new String("              J3D Timer                System Timer\n");
    TextArea textArea = new TextArea(header, 12, 35, TextArea.SCROLLBARS_NONE);
    panel.add(textArea);
    this.add(panel);

    for (int i = 0; i < ticks.length; i++) {
        ticks[i] = J3DTimer.getValue();//from  w w  w. ja v a2s.com
        sysTime[i] = System.currentTimeMillis();
    }

    for (int i = 0; i < ticks.length; i++)
        //System.out.println("tick "+ticks[i]+" "+sysTime[i] );
        textArea.append("tick " + ticks[i] + "    " + sysTime[i] + "\n");
    //System.out.println("Resolution "+J3DTimer.getResolution() );
    textArea.append("Resolution " + J3DTimer.getResolution() + "\n");

}

From source file:com.thoughtworks.go.agent.bootstrapper.osx.MacAboutBox.java

public MacAboutBox() {
    super("");
    setResizable(false);//from   www.  jav  a  2  s. com
    addWindowListener(new SymWindow());

    getContentPane().setLayout(new BorderLayout(15, 15));

    List<JLabel> aboutLabels = new ArrayList<JLabel>();
    aboutLabels.add(emptyLabel());
    aboutLabels.add(titleLabel("Go Agent"));
    aboutLabels.add(bodyLabel("Bootstrapper Version " + getBootstrapperVersion()));
    aboutLabels.add(emptyLabel());
    aboutLabels.add(bodyLabel("Java Version " + System.getProperty("java.version")));
    aboutLabels.add(bodyLabel("Copyright (C) 2015 ThoughtWorks Inc."));
    aboutLabels.add(emptyLabel());

    Panel textPanel2 = new Panel(new GridLayout(aboutLabels.size(), 1));
    for (JLabel aboutLabel : aboutLabels) {
        textPanel2.add(aboutLabel);
    }

    getContentPane().add(textPanel2, BorderLayout.CENTER);
    pack();
    setLocation(FRAME_LEFT, FRAME_TOP);
    setSize(FRAME_WIDTH, FRAME_HEIGHT);
    setResizable(false);
}

From source file:SimpleMorph.java

/**
 * Constructor that generates the content using the class methods
 *///  w w w  .  j a  va 2 s.  c om
public SimpleMorph() {
    VirtualUniverse myUniverse = new VirtualUniverse();
    Locale myLocale = new Locale(myUniverse);
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));
    myLocale.addBranchGraph(buildContentBranch());
    setTitle("SimpleMorph");
    setSize(400, 400);
    setLayout(new BorderLayout());
    Panel bottom = new Panel();
    bottom.add(pyraButton);
    bottom.add(cubeButton);
    bottom.add(exitButton);
    add(BorderLayout.CENTER, myCanvas3D);
    add(BorderLayout.SOUTH, bottom);
    pyraButton.addActionListener(this);
    cubeButton.addActionListener(this);
    exitButton.addActionListener(this);
    setVisible(true);
}

From source file:SimpleSounds.java

public SimpleSounds() {
    VirtualUniverse myUniverse = new VirtualUniverse();
    Locale myLocale = new Locale(myUniverse);
    //              buildUniverse(myCanvas3D);
    myLocale.addBranchGraph(buildContentBranch());
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));
    setTitle("SimpleSounds");
    setSize(400, 400);/*w ww .  j ava2 s.c o m*/
    setLayout(new BorderLayout());
    Panel bottom = new Panel();
    bottom.add(sound1Button);
    bottom.add(sound2Button);
    bottom.add(exitButton);
    add(BorderLayout.CENTER, myCanvas3D);
    add(BorderLayout.SOUTH, bottom);
    exitButton.addActionListener(this);
    sound1Button.addActionListener(this);
    sound2Button.addActionListener(this);
    setVisible(true);
}