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

public void init() {

    Panel buttonPanel = new PanelWithInsets(0, 0, 0, 0);
    buttonPanel.setLayout(new GridLayout(3, 2, 5, 5));
    buttonPanel.add(new GrayButton(ExposedIntStringTable.increment));
    buttonPanel.add(new GrayButton(ExposedIntStringTable.decrement));
    buttonPanel.add(minimumButton);//  w  ww .jav  a 2 s  . co  m
    buttonPanel.add(maximumButton);
    buttonPanel.add(zeroButton);
    buttonPanel.add(new GrayButton(ExposedIntStringTable.negate));
    zeroButton.disable();

    binaryField = new Label("00000000000000000000000000000000");
    hexField = new Label("00000000");
    decimalField = new Label("0");

    Font fieldFont = new Font("TimesRoman", Font.PLAIN, 12);
    binaryField.setFont(fieldFont);
    hexField.setFont(fieldFont);
    decimalField.setFont(fieldFont);

    Panel numberPanel = new Panel();
    numberPanel.setBackground(Color.white);
    numberPanel.setLayout(new GridLayout(3, 1));
    Panel binaryPanel = new Panel();
    binaryPanel.setLayout(new BorderLayout());
    binaryPanel.add("Center", binaryField);
    numberPanel.add(binaryPanel);

    Panel hexPanel = new Panel();
    hexPanel.setLayout(new BorderLayout());
    hexPanel.add("Center", hexField);
    numberPanel.add(hexPanel);
    numberPanel.add(decimalField);

    Panel labelPanel = new Panel();
    labelPanel.setBackground(Color.white);
    labelPanel.setLayout(new GridLayout(3, 1));
    Label label = new Label(ExposedIntStringTable.binary, Label.CENTER);
    Font labelFont = new Font("Helvetica", Font.ITALIC, 11);
    label.setFont(labelFont);
    labelPanel.add(label);
    label = new Label(ExposedIntStringTable.hex, Label.CENTER);
    label.setFont(labelFont);
    labelPanel.add(label);
    label = new Label(ExposedIntStringTable.decimal, Label.CENTER);
    label.setFont(labelFont);
    labelPanel.add(label);

    Panel dataPanel = new Panel();
    dataPanel.setLayout(new BorderLayout());
    dataPanel.add("West", labelPanel);
    dataPanel.add("Center", numberPanel);

    ColoredLabel title = new ColoredLabel(ExposedIntStringTable.title, Label.CENTER, Color.yellow);
    title.setFont(new Font("Helvetica", Font.BOLD, 12));

    setBackground(Color.red);
    setLayout(new BorderLayout(5, 5));
    add("North", title);
    add("West", buttonPanel);
    add("Center", dataPanel);
}

From source file:ControlQueryPApplet.java

/***************************************************************************
 * Respond to ControllerEvents from the Player that was created. For the
 * bare bones player the only event of import is the RealizeCompleteEvent.
 * At that stage the visual component and controller for the Player can
 * finally be obtained and thus displayed.
 **************************************************************************/
public synchronized void controllerUpdate(ControllerEvent e) {

    if (e instanceof RealizeCompleteEvent) {
        Control[] allControls = player.getControls();
        System.out.println("" + allControls.length + " controls for a Player @ REALIZED:");
        for (int i = 0; i < allControls.length; i++)
            System.out.println("" + (i + 1) + ": " + allControls[i]);
        add(player.getVisualComponent(), "North");
        add(player.getControlPanelComponent(), "South");
        validate();//from   ww w  .  j a va  2  s  . c  o m
    } else if (e instanceof StartEvent) {
        Control[] allControls = player.getControls();
        System.out.println("" + allControls.length + " controls for a Player @ START:");
        Panel panel = new Panel();
        for (int i = 0; i < allControls.length; i++) {
            System.out.println("" + (i + 1) + ": " + allControls[i]);
            Component cont = allControls[i].getControlComponent();
            if (cont != null) {
                System.out.println("Has a graphical component");
                panel.add(cont);
            }
        }
        panel.validate();
        add(panel, "Center");
        validate();
        FrameGrabbingControl frameControl = (FrameGrabbingControl) player
                .getControl("javax.media.control.FrameGrabbingControl");
        if (frameControl == null)
            System.out.println("Unable to obtain FrameRateControl");
        else {
            System.out.println("Have Frame Rate control");
            panel.add(frameControl.getControlComponent());
            panel.validate();
        }

    }

}

From source file:br.upe.ecomp.dosa.controller.chart.FileLineChartManager.java

private Panel createContents(double[] values, boolean logarithmicYAxis, String measurement, int step,
        File file) {/*from  w  w w . j a  v  a  2s  . c o m*/
    Panel chartPanel = new Panel();

    chartPanel.setLayout(new java.awt.GridLayout(1, 1));

    JFreeChart chart = createChart("", "Sample", "Fitness", createSampleDataset(values, measurement, step),
            false);

    ImageSaver.saveImage(chart.createBufferedImage(1000, 800), file.getParent(), "graph.png");

    ChartPanel jFreeChartPanel = new ChartPanel(chart);
    chartPanel.add(jFreeChartPanel);

    return chartPanel;
}

From source file:edu.harvard.i2b2.eclipse.plugins.patientMapping.views.PatientMappingView.java

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.// w  ww .  j  a  va  2  s.  c  om
 */
@Override
public void createPartControl(Composite parent) {
    log.info("Patient Mapping plugin version 1.7.0");
    timelineComposite = parent;

    if (!(UserInfoBean.getInstance().isRoleInProject("DATA_LDS"))) {
        new NoAccessComposite(parent, SWT.NONE);
        return;
    }

    //explorer = new MainComposite(parent, false);*/

    Composite composite = new Composite(parent, SWT.EMBEDDED);

    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer = runRoot.getContentPane();

    runTreePanel = new PatientMappingJPanel(oAwtContainer);//PreviousQueryPanel(this);
    //runTreePanel.setBackground(Color.BLUE);

    oAwtContainer.add(runTreePanel);

    // Setup help context
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, PATIENTMAPPING_VIEW_CONTEXT_ID);
    addHelpButtonToToolBar();
}

From source file:edu.harvard.i2b2.eclipse.plugins.query.views.QueryView.java

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it./* w w  w.j a  v  a  2 s .c o m*/
 */
@Override
public void createPartControl(Composite parent) {

    // setup context help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, QUERY_VIEW_CONTEXT_ID);
    addHelpButtonToToolBar();

    log.info("Query Tool plugin version 1.7.0");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    parent.setLayout(topGridLayout);

    queryComposite = new Composite(parent, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    Composite rightComp = new Composite(queryComposite, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        queryToolPanel = new QueryToolInvestigatorPanel(this);
    } else {
        queryToolPanel = new QueryToolPanel();
    }

    oAwtContainer.add(queryToolPanel);

}

From source file:br.upe.ecomp.dosa.controller.chart.FileLineChartDirectorManager.java

/**
 * {@inheritDoc}/*from   www .  jav a2  s. c o  m*/
 */
// public Panel plot(List<File> files, String measurement, int step, boolean logarithmicYAxis) {
// Integer lastIteration = resultsAnalyzer.getLastIteration(files);
// double[] data = resultsAnalyzer.getDataMeans(files, measurement, lastIteration, step);
// return createContents(data, logarithmicYAxis, measurement, step);
// }

private Panel createContents(double[] values, boolean logarithmicYAxis, String measurement, int step) {
    Panel chartPanel = new Panel();

    chartPanel.setLayout(new java.awt.GridLayout(1, 1));

    JFreeChart chart = createChart("", "Sample", "Fitness", createSampleDataset(values, measurement, step),
            false);

    ChartPanel jFreeChartPanel = new ChartPanel(chart);
    chartPanel.add(jFreeChartPanel);

    return chartPanel;
}

From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.views.AdminToolView.java

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//w  w w .  j a v  a2s . c o m
 */
@Override
public void createPartControl(Composite parent) {
    log.info("Patient Mapping plugin version 1.7.0");
    timelineComposite = parent;

    boolean isManager = false;
    ArrayList<String> roles = (ArrayList<String>) UserInfoBean.getInstance().getProjectRoles();
    for (String param : roles) {
        if (param.equalsIgnoreCase("manager")) {
            isManager = true;
            break;
        }
    }

    if (!(UserInfoBean.getInstance().isRoleInProject("DATA_PROT")) || !isManager) {
        new NoAccessComposite(parent, SWT.NONE);
        return;
    }

    //explorer = new MainComposite(parent, false);*/

    Composite composite = new Composite(parent, SWT.EMBEDDED);

    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer = runRoot.getContentPane();

    runTreePanel = new AdminToolJPanel();//PatientMappingJPanel();//PreviousQueryPanel(this);
    //runTreePanel.setBackground(Color.BLUE);

    oAwtContainer.add(runTreePanel);

    // Setup help context
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ADMINTOOL_VIEW_CONTEXT_ID);
    addHelpButtonToToolBar();
}

From source file:br.upe.ecomp.dosa.controller.chart.FileLineChartDirectorManager.java

private Panel createContentsChartDirector(double[] values, boolean logarithmicYAxis, String measurement,
        int step) {
    Panel chartPanel = new Panel();

    chartPanel.setLayout(new java.awt.GridLayout(1, 1));

    chartPanel.setBackground(Color.white);

    // Create the chart and put them in the content pane
    ChartViewer viewer = new ChartViewer();
    this.createChart(viewer, chartPanel, values, step);
    chartPanel.add(viewer);

    // JFreeChart chart = createChart("", "Sample", "Fitness", createSampleDataset(values,
    // measurement, step), false);
    //// w  w  w .ja  v  a2s .c om
    // ChartPanel jFreeChartPanel = new ChartPanel(chart);
    // chartPanel.add(jFreeChartPanel);

    return chartPanel;
}

From source file:WebCrawler.java

public void init() {

    // set up the main UI panel
    panelMain = new Panel();
    panelMain.setLayout(new BorderLayout(5, 5));

    // text entry components
    Panel panelEntry = new Panel();
    panelEntry.setLayout(new BorderLayout(5, 5));

    Panel panelURL = new Panel();
    panelURL.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    Label labelURL = new Label("Starting URL: ", Label.RIGHT);
    panelURL.add(labelURL);
    textURL = new TextField("", 40);
    panelURL.add(textURL);//from w ww. jav  a2s.c o m
    panelEntry.add("North", panelURL);

    Panel panelType = new Panel();
    panelType.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    Label labelType = new Label("Content type: ", Label.RIGHT);
    panelType.add(labelType);
    choiceType = new Choice();
    choiceType.addItem("text/html");
    choiceType.addItem("audio/basic");
    choiceType.addItem("audio/au");
    choiceType.addItem("audio/aiff");
    choiceType.addItem("audio/wav");
    choiceType.addItem("video/mpeg");
    choiceType.addItem("video/x-avi");
    panelType.add(choiceType);
    panelEntry.add("South", panelType);

    panelMain.add("North", panelEntry);

    // list of result URLs
    Panel panelListButtons = new Panel();
    panelListButtons.setLayout(new BorderLayout(5, 5));

    Panel panelList = new Panel();
    panelList.setLayout(new BorderLayout(5, 5));
    Label labelResults = new Label("Search results");
    panelList.add("North", labelResults);
    Panel panelListCurrent = new Panel();
    panelListCurrent.setLayout(new BorderLayout(5, 5));
    listMatches = new List(10);
    panelListCurrent.add("North", listMatches);
    labelStatus = new Label("");
    panelListCurrent.add("South", labelStatus);
    panelList.add("South", panelListCurrent);

    panelListButtons.add("North", panelList);

    // control buttons
    Panel panelButtons = new Panel();
    Button buttonSearch = new Button(SEARCH);
    buttonSearch.addActionListener(this);
    panelButtons.add(buttonSearch);
    Button buttonStop = new Button(STOP);
    buttonStop.addActionListener(this);
    panelButtons.add(buttonStop);

    panelListButtons.add("South", panelButtons);

    panelMain.add("South", panelListButtons);

    add(panelMain);
    setVisible(true);

    repaint();

    // initialize search data structures
    vectorToSearch = new Vector();
    vectorSearched = new Vector();
    vectorMatches = new Vector();

    // set default for URL access
    URLConnection.setDefaultAllowUserInteraction(false);
}

From source file:edu.harvard.i2b2.query.QueryC.java

/**
 * @param args//from w ww  .  j  a  v a 2 s  .  c  o m
 */
protected Control createContents(Composite parent) {
    //log.info("Starting Query Mode");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    setLayout(topGridLayout);

    Composite queryComposite = new Composite(this, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    // the horizontal sash form
    SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL);
    horizontalForm.setOrientation(SWT.HORIZONTAL);
    horizontalForm.setLayout(new GridLayout());

    //left sash form
    SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    leftVerticalForm.setOrientation(SWT.VERTICAL);
    leftVerticalForm.setLayout(new GridLayout());

    if (bWantStatusLine) {
        slm.createControl(this, SWT.NULL);
    }
    slm.setMessage("i2b2 Explorer Version 2.0");
    slm.update(true);

    // Create the tab folder
    final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    // Create each tab and set its text, tool tip text,
    // image, and control
    TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE);
    oTreeTab.setText("Concept trees");
    oTreeTab.setToolTipText("Hierarchically organized patient characteristics");
    oTreeTab.setControl(getQueryTabControl(oTabFolder));

    //TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE);
    //oFindTab.setText("Find");
    //oFindTab.setToolTipText("Free-form find tool for patient characteristics");
    //FindTool find = new FindTool(slm);

    //oFindTab.setControl(find.getFindTabControl(oTabFolder));

    // Select the first tab (index is zero-based)
    oTabFolder.setSelection(0);

    // Create the tab folder
    final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE);
    previousRunTab.setText("Patient Sets and Previous Queries");
    previousRunTab.setToolTipText("Patient Sets & Previous Queries");
    final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED);
    previousRunTab.setControl(composite);

    /* Create and setting up frame */
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer_left = runRoot.getContentPane();

    //runTreePanel = new QueryPreviousRunsPanel(this, null);
    //oAwtContainer_left.add(runTreePanel);

    // Select the first tab (index is zero-based)
    queryRunFolder.setSelection(0);

    final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    verticalForm.setOrientation(SWT.VERTICAL);
    verticalForm.setLayout(null);

    Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        queryPanel = new QueryPanelInvestigator(this);
    } else {
        queryPanel = new QueryPanel(this);
    }

    oAwtContainer.add(queryPanel);
    queryPanel.setSplitBounds(oAwtContainer.getBounds());

    if (mode_ == 0) {
        //bottomC = new ExplorerC(verticalForm, false);
        verticalForm.setWeights(new int[] { 40, 50 });
    }
    verticalForm.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            if (mode_ == 0) {
                int height = verticalForm.getBounds().height;
                //System.out.println("Height: "+height);
                if (height > 285) {
                    try {
                        verticalForm.setWeights(new int[] { 285, height - 285 });
                    } catch (Exception e) {
                        return;
                    }
                }
            }
        }
    });

    horizontalForm.setWeights(new int[] { 20, 70 });
    return parent;
}