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

public void addUiToPanel(Panel panel) {
    panel.add(new Label("AmbientLight"));
    super.addUiToPanel(panel);
}

From source file:com.microsoft.tfs.client.common.ui.controls.generic.CompatibleBrowser.java

public CompatibleBrowser(final Composite parent, final int style) {
    super(parent, style);

    Check.notNull(parent, "parent"); //$NON-NLS-1$

    final GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginHeight = 0;/*from w  w  w .j  a  v a 2s. com*/
    gridLayout.marginWidth = 0;

    setLayout(gridLayout);

    if (isNativeBrowserAvailable()) {
        log.info(MessageFormat.format("{0} using SWT Browser", CompatibleBrowser.class.getName())); //$NON-NLS-1$

        final GridData gd = new GridData();
        gd.grabExcessHorizontalSpace = true;
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessVerticalSpace = true;
        gd.verticalAlignment = SWT.FILL;

        browser = new Browser(this, style);
        browser.setLayoutData(gd);

        editorPane = null;
    } else {
        log.info(MessageFormat.format("{0} using JEditorPane", CompatibleBrowser.class.getName())); //$NON-NLS-1$

        browser = null;

        JEditorPane tempEditorPane = null;
        CompatibilityLinkControl tempErrorLabel = null;

        /*
         * Embedded AWT widgets must be in a Composite with SWT.EMBEDDED
         * set, so create one.
         */
        final Composite embeddableComposite = new Composite(this, SWT.EMBEDDED);

        final GridData compositeGridData = new GridData();
        compositeGridData.grabExcessHorizontalSpace = true;
        compositeGridData.horizontalAlignment = SWT.FILL;
        compositeGridData.grabExcessVerticalSpace = true;
        compositeGridData.verticalAlignment = SWT.FILL;

        embeddableComposite.setLayoutData(compositeGridData);

        /*
         * We have to skip trying AWT entirely some places.
         */
        boolean loadedAWTBrowser = false;
        if (CompatibleBrowser.isAWTDangerousHere() == false) {
            try {
                /*
                 * Create a Frame in the SWT Composite as the top-level
                 * element.
                 */
                final Frame browserFrame = SWT_AWT.new_Frame(embeddableComposite);

                /*
                 * Create a panel with a simple BorderLayout to hold
                 * contents.
                 */
                final Panel panel = new Panel(new BorderLayout());
                browserFrame.add(panel);

                /*
                 * Create an JEditorPane with an HTML document.
                 */
                final String pageContents = "<html><body></body></html>"; //$NON-NLS-1$
                tempEditorPane = new JEditorPane("text/html", pageContents); //$NON-NLS-1$
                tempEditorPane.setEditable(false);

                /*
                 * Put the HTML viewer in a scroll pane and parent the
                 * scroll pane in the panel.
                 */
                final JScrollPane scrollPane = new JScrollPane(tempEditorPane);
                panel.add(scrollPane);

                loadedAWTBrowser = true;
            } catch (final Throwable t) {
                log.warn("Error embedding AWT frame for JEditorPane", t); //$NON-NLS-1$
            }
        }

        if (loadedAWTBrowser == false) {
            /*
             * We don't need the embeddable composite because AWT embedding
             * failed, and we can't put normal (error label) things in it,
             * so hide it.
             */
            compositeGridData.widthHint = 0;
            compositeGridData.heightHint = 0;

            tempErrorLabel = CompatibilityLinkFactory.createLink(this, SWT.NONE);

            tempErrorLabel.setText(
                    MessageFormat.format(Messages.getString("CompatibleBrowser.CouldNotLoadSWTBrowserFormat"), //$NON-NLS-1$
                            AWT_TOOLKIT_ENV_VAR_NAME, XTOOLKIT_ENV_VAR_VALUE));

            final GridData labelGridData = new GridData();
            labelGridData.grabExcessHorizontalSpace = true;
            labelGridData.horizontalAlignment = SWT.FILL;
            labelGridData.grabExcessVerticalSpace = true;
            labelGridData.verticalAlignment = SWT.FILL;

            tempErrorLabel.getControl().setLayoutData(labelGridData);
        }

        editorPane = tempEditorPane;
    }
}

From source file:tracing.ShollAnalysisDialog.java

public ShollAnalysisDialog(String title, double x_start, double y_start, double z_start,
        PathAndFillManager pafm, ImagePlus originalImage) {

    super(IJ.getInstance(), title, false);

    this.x_start = x_start;
    this.y_start = y_start;
    this.z_start = z_start;

    this.originalImage = originalImage;
    twoDimensional = (originalImage.getStackSize() == 1);

    shollPointsAllPaths = new ArrayList<ShollPoint>();
    shollPointsSelectedPaths = new ArrayList<ShollPoint>();

    numberOfAllPaths = 0;/* w w w. j  av a2  s .  c o  m*/
    numberOfSelectedPaths = 0;

    for (Path p : pafm.allPaths) {
        boolean selected = p.getSelected();
        if (p.getUseFitted()) {
            p = p.fitted;
        } else if (p.fittedVersionOf != null)
            continue;
        addPathPointsToShollList(p, x_start, y_start, z_start, shollPointsAllPaths);
        ++numberOfAllPaths;
        if (selected) {
            addPathPointsToShollList(p, x_start, y_start, z_start, shollPointsSelectedPaths);
            ++numberOfSelectedPaths;
        }
    }

    useAllPathsCheckbox.setLabel("Use all " + numberOfAllPaths + " paths in analysis?");
    useSelectedPathsCheckbox.setLabel("Use only the " + numberOfSelectedPaths + " selected paths in analysis?");

    addWindowListener(this);

    setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    int margin = 10;
    c.insets = new Insets(margin, margin, 0, margin);
    useAllPathsCheckbox.addItemListener(this);
    add(useAllPathsCheckbox, c);

    ++c.gridy;
    c.insets = new Insets(0, margin, margin, margin);
    add(useSelectedPathsCheckbox, c);
    useSelectedPathsCheckbox.addItemListener(this);

    ++c.gridy;
    c.insets = new Insets(margin, margin, 0, margin);
    add(normalAxes, c);
    normalAxes.addItemListener(this);
    ++c.gridy;
    c.insets = new Insets(0, margin, 0, margin);
    add(semiLogAxes, c);
    semiLogAxes.addItemListener(this);
    ++c.gridy;
    c.insets = new Insets(0, margin, margin, margin);
    add(logLogAxes, c);
    logLogAxes.addItemListener(this);

    ++c.gridy;
    c.insets = new Insets(margin, margin, 0, margin);
    add(noNormalization, c);
    noNormalization.addItemListener(this);
    ++c.gridy;
    c.insets = new Insets(0, margin, margin, margin);
    if (twoDimensional)
        normalizationForSphereVolume.setLabel("Normalize for area enclosed by circle");
    else
        normalizationForSphereVolume.setLabel("Normalize for volume enclosed by circle");
    add(normalizationForSphereVolume, c);
    normalizationForSphereVolume.addItemListener(this);

    ++c.gridy;
    c.gridx = 0;
    Panel separationPanel = new Panel();
    separationPanel.add(new Label("Circle / sphere separation (0 for unsampled analysis)"));
    sampleSeparation.addTextListener(this);
    separationPanel.add(sampleSeparation);
    add(separationPanel, c);

    c.gridx = 0;
    ++c.gridy;
    c.insets = new Insets(margin, margin, margin, margin);
    add(resultsPanel, c);

    ++c.gridy;
    Panel buttonsPanel = new Panel();
    buttonsPanel.setLayout(new BorderLayout());
    Panel topRow = new Panel();
    Panel middleRow = new Panel();
    Panel bottomRow = new Panel();

    topRow.add(makeShollImageButton);
    makeShollImageButton.addActionListener(this);

    topRow.add(drawShollGraphButton);
    drawShollGraphButton.addActionListener(this);

    middleRow.add(exportDetailAsCSVButton);
    exportDetailAsCSVButton.addActionListener(this);

    middleRow.add(exportSummaryAsCSVButton);
    exportSummaryAsCSVButton.addActionListener(this);

    bottomRow.add(addToResultsTableButton);
    addToResultsTableButton.addActionListener(this);

    buttonsPanel.add(topRow, BorderLayout.NORTH);
    buttonsPanel.add(middleRow, BorderLayout.CENTER);
    buttonsPanel.add(bottomRow, BorderLayout.SOUTH);

    add(buttonsPanel, c);

    pack();

    GUI.center(this);
    setVisible(true);

    updateResults();
}

From source file:BehaviorTest.java

public BehaviorTest() {
    initJava3d();/*w  ww . j a  va  2 s.  com*/

    Panel controlPanel = new Panel();

    Button rotateButton = new Button("Rotate");
    rotateButton.addActionListener(this);
    controlPanel.add(rotateButton);

    Button objSizeButton = new Button("Object Size");
    objSizeButton.addActionListener(this);
    controlPanel.add(objSizeButton);

    Button explodeButton = new Button("Explode");
    explodeButton.addActionListener(this);
    controlPanel.add(explodeButton);

    Button stretchButton = new Button("Stretch");
    stretchButton.addActionListener(this);
    controlPanel.add(stretchButton);

    Button boundsButton = new Button("Bounds");
    boundsButton.addActionListener(this);
    controlPanel.add(boundsButton);

    Button fpsButton = new Button("FPS");
    fpsButton.addActionListener(this);
    controlPanel.add(fpsButton);

    add(controlPanel, BorderLayout.SOUTH);
}

From source file:LightTest.java

public void addUiToPanel(Panel panel) {
    Button colorButton = new Button("Color");
    colorButton.addActionListener(this);
    panel.add(colorButton);

    m_EnableCheck = new Checkbox("Enable", true);
    m_EnableCheck.addItemListener(this);
    panel.add(m_EnableCheck);/*from   ww  w .j  ava2  s .  co  m*/

    panel.add(new Label("Bounds:"));

    panel.add(new Label("X:"));
    m_XTextField = new TextField(3);
    panel.add(m_XTextField);

    panel.add(new Label("Y:"));
    m_YTextField = new TextField(3);
    panel.add(m_YTextField);

    panel.add(new Label("Z:"));
    m_ZTextField = new TextField(3);
    panel.add(m_ZTextField);

    panel.add(new Label("Radius:"));
    m_RadiusTextField = new TextField(4);
    panel.add(m_RadiusTextField);

    Button updateButton = new Button("Update");
    updateButton.addActionListener(this);
    panel.add(updateButton);

    synchLightToUi();
}

From source file:LightTest.java

public void addUiToPanel(Panel panel) {
    m_XDirectionTextField = new TextField(3);
    m_YDirectionTextField = new TextField(3);
    m_ZDirectionTextField = new TextField(3);

    panel.add(new Label("Direction:"));
    panel.add(new Label("X:"));
    panel.add(m_XDirectionTextField);//from w  ww. ja v a  2  s.co  m
    panel.add(new Label("Y:"));
    panel.add(m_YDirectionTextField);
    panel.add(new Label("Z:"));
    panel.add(m_ZDirectionTextField);

    super.addUiToPanel(panel);
}

From source file:LightTest.java

public void addUiToPanel(Panel panel) {
    m_XDirectionTextField = new TextField(3);
    m_YDirectionTextField = new TextField(3);
    m_ZDirectionTextField = new TextField(3);

    m_ConcentrationTextField = new TextField(3);
    m_SpreadAngleTextField = new TextField(3);

    panel.add(new Label("Direction:"));
    panel.add(new Label("X:"));
    panel.add(m_XDirectionTextField);//from   w w  w. j ava  2 s.  c  o m
    panel.add(new Label("Y:"));
    panel.add(m_YDirectionTextField);
    panel.add(new Label("Z:"));
    panel.add(m_ZDirectionTextField);

    panel.add(new Label("Concentration:"));
    panel.add(m_ConcentrationTextField);

    panel.add(new Label("Spread Angle:"));
    panel.add(m_SpreadAngleTextField);

    super.addUiToPanel(panel);
}

From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

private void setKey() {
    if (right != null && !right.isDisposed()) {
        right.dispose();/*from  w ww. j  av  a  2  s  .c  o m*/
        right = null;
    }

    right = new Composite(composite, SWT.NONE);
    GridLayout rightLayout1 = new GridLayout();
    GridData rightLData = new GridData();
    rightLData.grabExcessHorizontalSpace = true;
    rightLData.grabExcessVerticalSpace = true;
    rightLData.horizontalAlignment = GridData.FILL;
    rightLData.verticalAlignment = GridData.FILL;
    right.setLayoutData(rightLData);
    right.setLayout(rightLayout1);
    GridData composite1LData = new GridData();
    composite1LData.grabExcessHorizontalSpace = true;
    composite1LData.grabExcessVerticalSpace = true;
    composite1LData.horizontalAlignment = GridData.FILL;
    composite1LData.verticalAlignment = GridData.FILL;

    composite1 = new Composite(right, SWT.EMBEDDED);
    composite1.setLayoutData(composite1LData);

    /* 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(composite1);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        System.out.println("Error setting native LAF: " + e1);
    }

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

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

    oAwtContainer.add(runTreePanel);
    //oAwtContainer.setVisible(true);
    //oAwtContainer.setSize(500, 500);

    //right.layout(true);
    //right.setVisible(true);
    //right.update();

    composite.layout(true);
    //composite.setVisible(true);
    //composite.update();
}

From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

private void setPassword() {
    if (right != null && !right.isDisposed()) {
        right.dispose();//from  ww w. j  a  v a 2s. c  o m
        right = null;
    }

    right = new Composite(composite, SWT.NONE);
    GridLayout rightLayout1 = new GridLayout();
    GridData rightLData = new GridData();
    rightLData.grabExcessHorizontalSpace = true;
    rightLData.grabExcessVerticalSpace = true;
    rightLData.horizontalAlignment = GridData.FILL;
    rightLData.verticalAlignment = GridData.FILL;
    right.setLayoutData(rightLData);
    right.setLayout(rightLayout1);
    GridData composite1LData = new GridData();
    composite1LData.grabExcessHorizontalSpace = true;
    composite1LData.grabExcessVerticalSpace = true;
    composite1LData.horizontalAlignment = GridData.FILL;
    composite1LData.verticalAlignment = GridData.FILL;

    composite1 = new Composite(right, SWT.EMBEDDED);
    composite1.setLayoutData(composite1LData);

    /* 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(composite1);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        System.out.println("Error setting native LAF: " + e1);
    }

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

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

    oAwtContainer.add(runTreePanel);
    //oAwtContainer.setVisible(true);
    //oAwtContainer.setSize(500, 500);

    //right.layout(true);
    //right.setVisible(true);
    //right.update();

    composite.layout(true);
    //composite.setVisible(true);
    //composite.update();
}

From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

private void audit() {
    //System.out.println(item.getText()+" item selected");
    //group.setVisible(false);
    //composite1.setVisible(true);
    if (right != null && !right.isDisposed()) {
        right.dispose();//from   w  ww .j a  va  2 s  . c o  m
        right = null;
    }

    right = new Composite(composite, SWT.NONE);
    GridLayout rightLayout1 = new GridLayout();
    GridData rightLData = new GridData();
    rightLData.grabExcessHorizontalSpace = true;
    rightLData.grabExcessVerticalSpace = true;
    rightLData.horizontalAlignment = GridData.FILL;
    rightLData.verticalAlignment = GridData.FILL;
    right.setLayoutData(rightLData);
    right.setLayout(rightLayout1);
    GridData composite1LData = new GridData();
    composite1LData.grabExcessHorizontalSpace = true;
    composite1LData.grabExcessVerticalSpace = true;
    composite1LData.horizontalAlignment = GridData.FILL;
    composite1LData.verticalAlignment = GridData.FILL;

    composite1 = new Composite(right, SWT.EMBEDDED);
    composite1.setLayoutData(composite1LData);

    /* 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(composite1);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        System.out.println("Error setting native LAF: " + e1);
    }

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

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

    oAwtContainer.add(runTreePanel);
    //oAwtContainer.setVisible(true);
    //oAwtContainer.setSize(500, 500);

    //right.layout(true);
    //right.setVisible(true);
    //right.update();

    composite.layout(true);
    //composite.setVisible(true);
    //composite.update();
}