Example usage for java.awt GridBagConstraints RELATIVE

List of usage examples for java.awt GridBagConstraints RELATIVE

Introduction

In this page you can find the example usage for java.awt GridBagConstraints RELATIVE.

Prototype

int RELATIVE

To view the source code for java.awt GridBagConstraints RELATIVE.

Click Source Link

Document

Specifies that this component is the next-to-last component in its column or row ( gridwidth , gridheight ), or that this component be placed next to the previously added component ( gridx , gridy ).

Usage

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

private void appendGenerationsSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {//from  w w  w.jav a 2 s .  com
    SpinnerModel generationsModel = new SpinnerNumberModel(generationsInitial, GENERATIONS_MIN, GENERATIONS_MAX,
            GENERATIONS_STEP);
    generationsSpinner = new JSpinner(generationsModel);
    generationsSpinner.setEnabled(false);
    JLabel generationsLabel = new JLabel(generationsText);
    generationsLabel.setLabelFor(generationsSpinner);

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(generationsLabel, constraints);
    mainPanel.add(generationsLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(generationsSpinner, constraints);
    mainPanel.add(generationsSpinner);
}

From source file:gda.gui.mca.McaGUI.java

private void makePlotPanel() {
    plotPanel = new JPanel();
    // String[] v = {"Plot Channel Number", "Plot Energy"};
    // xaxisCombo = new JComboBox(v);
    configLabel = new JLabel("         ");
    JPanel pane = new JPanel();
    adcControl = new JButton("Adc Controls");
    adcControl.addActionListener(new ActionListener() {

        @Override//ww  w.j ava2 s.c  o  m
        public void actionPerformed(ActionEvent e) {
            if (adcControlPanel != null)
                adcDialog.setVisible(true);
        }

    });
    tcaControl = new JButton("Tca Controls");
    tcaControl.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (tcaControlPanel != null)
                tcaDialog.setVisible(true);
        }

    });
    makeAdcControlDialog();
    makeTcaControlDialog();
    pane.setLayout(new GridBagLayout());
    GridBagConstraints gcs = new GridBagConstraints();
    gcs.gridx = 0;
    gcs.gridy = 0;
    gcs.gridwidth = GridBagConstraints.RELATIVE;
    // pane.add(xaxisCombo, gcs);
    gcs.gridx++;
    // gcs.gridwidth = GridBagConstraints.REMAINDER;
    pane.add(configLabel, gcs);
    gcs.gridx = GridBagConstraints.RELATIVE;
    pane.add(Box.createHorizontalStrut(500), gcs);
    pane.add(adcControl, gcs);
    pane.add(tcaControl, gcs);
    plotPanel.setLayout(new BorderLayout());
    plotPanel.add(getSimplePlot(), BorderLayout.CENTER);
    plotPanel.add(pane, BorderLayout.SOUTH);

}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

private void appendRunContinuouslyCheckBox(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {/* w  ww.j av  a  2  s  . c om*/
    runContinuouslyCheckBox = new JCheckBox(continuousText);
    runContinuouslyCheckBox.addActionListener(getRunContinuouslyCheckBoxActionListener());
    runContinuouslyCheckBox.setSelected(true);

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    JLabel dummyJLabel = new JLabel();
    gridBagLayout.setConstraints(dummyJLabel, constraints);
    mainPanel.add(dummyJLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(runContinuouslyCheckBox, constraints);
    mainPanel.add(runContinuouslyCheckBox);
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 *
 *///from   w  w w.java2 s  . c o m
private void createComponents() {

    // creat popup menus
    {

        popupMenu = new JPopupMenu();
        removeMenuItem = new JMenuItem(I18N
                .getGUILabel("plotter.configuration_dialog.color_scheme_dialog.remove_color_menu_item.label"));
        removeMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                removeSelectedColorAction();
            }

        });
        popupMenu.add(removeMenuItem);

        changeColorMenuItem = new JMenuItem(I18N
                .getGUILabel("plotter.configuration_dialog.color_scheme_dialog.change_color_menu_item.label"));
        changeColorMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                replaceSelectedColorAction();
            }

        });
        popupMenu.add(changeColorMenuItem);

        popupMenu.addSeparator();

        moveUpColorMenuItem = new JMenuItem(
                I18N.getGUILabel("plotter.configuration_dialog.color_scheme_dialog.move_up_menu_item.label"));
        moveUpColorMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                moveSelectedColorUpAction();

            }

        });
        popupMenu.add(moveUpColorMenuItem);

        moveDownColorMenuItem = new JMenuItem(
                I18N.getGUILabel("plotter.configuration_dialog.color_scheme_dialog.move_down_menu_item.label"));
        moveDownColorMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                moveSelectedColorDownAction();
            }

        });
        popupMenu.add(moveDownColorMenuItem);

    }

    JPanel containerPanel = new JPanel(new GridBagLayout());
    containerPanel.setPreferredSize(new Dimension(520, 450));

    // create containing panel
    {

        {
            JPanel configurePanel = new JPanel(new GridBagLayout());
            configurePanel.setPreferredSize(new Dimension(220, 400));
            configurePanel.setBorder(BorderFactory.createTitledBorder(I18N.getGUILabel(
                    "plotter.configuration_dialog.color_scheme_dialog.scheme_configuration_border.label")));

            // add scheme list panel
            {
                JPanel schemeComboBoxPanel = createSchemeComboBoxPanel();

                // add category choosing panel
                GridBagConstraints itemConstraint = new GridBagConstraints();
                itemConstraint.fill = GridBagConstraints.BOTH;
                itemConstraint.weightx = 1;
                itemConstraint.weighty = 1;
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.insets = new Insets(2, 2, 2, 5);

                configurePanel.add(schemeComboBoxPanel, itemConstraint);
            }

            {
                categoryAndGradientConfigPanel = new JPanel(new GridBagLayout());

                // add categories panel
                {
                    JPanel categoryConfigurationPanel = createColorCategoriesPanel();

                    // add category choosing panel
                    GridBagConstraints itemConstraint = new GridBagConstraints();
                    itemConstraint.fill = GridBagConstraints.BOTH;
                    itemConstraint.weightx = 1;
                    itemConstraint.weighty = 1;
                    itemConstraint.insets = new Insets(2, 2, 2, 5);
                    itemConstraint.gridwidth = GridBagConstraints.REMAINDER;

                    categoryAndGradientConfigPanel.add(categoryConfigurationPanel, itemConstraint);

                }

                // add gradient chooser panel
                {
                    JPanel gradientConfigPanel = createGradientConfigurationPanel();

                    GridBagConstraints itemConstraint = new GridBagConstraints();
                    itemConstraint.fill = GridBagConstraints.BOTH;
                    itemConstraint.weightx = 1;
                    itemConstraint.weighty = 1;
                    itemConstraint.insets = new Insets(2, 2, 2, 5);
                    itemConstraint.gridwidth = GridBagConstraints.REMAINDER;

                    categoryAndGradientConfigPanel.add(gradientConfigPanel, itemConstraint);
                }

                GridBagConstraints itemConstraint = new GridBagConstraints();
                itemConstraint.fill = GridBagConstraints.BOTH;
                itemConstraint.weightx = 1;
                itemConstraint.weighty = 1;
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.insets = new Insets(2, 2, 2, 5);

                configurePanel.add(categoryAndGradientConfigPanel, itemConstraint);

            }

            GridBagConstraints itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 1;
            itemConstraint.weighty = 1;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            containerPanel.add(configurePanel, itemConstraint);
        }

        createPlotPreviewPanel(containerPanel);

    }

    // create buttons
    Collection<AbstractButton> buttons = new LinkedList<AbstractButton>();
    buttons.add(makeOkButton());

    Action saveAction = new ResourceAction("plotter.configuration_dialog.color_scheme_dialog.save_button") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            save(currentColorSchemes, currentActiveColorSchemeName);

            // set new scheme
            plotConfig.setColorSchemes(currentColorSchemes, currentActiveColorSchemeName);
        }
    };
    saveButton = new JButton(saveAction);
    buttons.add(saveButton);
    saveButton.setEnabled(false);

    Action revertAction = new ResourceAction("plotter.configuration_dialog.color_scheme_dialog.revert_button") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            revert();
        }
    };
    revertButton = new JButton(revertAction);
    revertButton.setEnabled(false);
    buttons.add(revertButton);
    buttons.add(makeCancelButton("plotter.configuration_dialog.color_scheme_dialog.cancel_button"));

    layoutDefault(containerPanel, buttons);
}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

private void appendPopulationSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {// w ww . ja  v a 2s.  com
    SpinnerModel populationModel = new SpinnerNumberModel(populationInitial, POPULATION_MIN, POPULATION_MAX,
            POPULATION_STEP);
    populationSpinner = new JSpinner(populationModel);
    JLabel populationLabel = new JLabel(populationText);
    populationLabel.setLabelFor(populationSpinner);

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(populationLabel, constraints);
    mainPanel.add(populationLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(populationSpinner, constraints);
    mainPanel.add(populationSpinner);
}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

private void appendLifespanSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {//from  w w  w  . j av a2  s  .  c om
    SpinnerModel lifespanModel = new SpinnerNumberModel(lifespanInitial, LIFESPAN_MIN, LIFESPAN_MAX,
            LIFESPAN_STEP);
    lifespanSpinner = new JSpinner(lifespanModel);
    JLabel lifespanLabel = new JLabel(lifespanText);
    lifespanLabel.setLabelFor(lifespanSpinner);

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(lifespanLabel, constraints);
    mainPanel.add(lifespanLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(lifespanSpinner, constraints);
    mainPanel.add(lifespanSpinner);
}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

private void appendSurvivalRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {//from  w  w  w  .ja  v  a2  s . com
    SpinnerModel survivalRateModel = new SpinnerNumberModel(survivalInitial, SURVIVAL_MIN, SURVIVAL_MAX,
            SURVIVAL_STEP);
    survivalRateSpinner = new JSpinner(survivalRateModel);
    JLabel survivalRateLabel = new JLabel(survivalRateText);
    survivalRateLabel.setLabelFor(survivalRateSpinner);

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(survivalRateLabel, constraints);
    mainPanel.add(survivalRateLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(survivalRateSpinner, constraints);
    mainPanel.add(survivalRateSpinner);
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @param containerPanel/*www  .j  ava  2  s . c  o m*/
 */
private void createPlotPreviewPanel(JPanel containerPanel) {

    JPanel previewPanel = new JPanel(new GridBagLayout());
    previewPanel.setPreferredSize(new Dimension(300, 300));

    GridBagConstraints itemConstraint = new GridBagConstraints();
    itemConstraint.fill = GridBagConstraints.BOTH;
    itemConstraint.weightx = 1;
    itemConstraint.weighty = 1;
    itemConstraint.gridwidth = GridBagConstraints.REMAINDER;

    // nominal value color preview
    {
        nominalPreviewPanel = nominalPlotter.getChartPanel();
        nominalPreviewPanel.setPreferredSize(new Dimension(150, 150));
        previewPanel.add(nominalPreviewPanel, itemConstraint);
    }

    // add gradient preview
    {

        gradientPreviewPanel = gradientPlotter.getChartPanel();
        gradientPreviewPanel.setPreferredSize(new Dimension(150, 150));

        previewPanel.add(gradientPreviewPanel, itemConstraint);

    }

    itemConstraint = new GridBagConstraints();
    itemConstraint.fill = GridBagConstraints.BOTH;
    itemConstraint.weightx = 1;
    itemConstraint.weighty = 1;
    itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
    containerPanel.add(previewPanel, itemConstraint);
}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

private void appendMutationRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {//from  ww  w .j  av  a2 s.c  o  m
    SpinnerModel mutationRateModel = new SpinnerNumberModel(mutationInitial, MUTATION_MIN, MUTATION_MAX,
            MUTATION_STEP);
    mutationRateSpinner = new JSpinner(mutationRateModel);
    JLabel mutationRateLabel = new JLabel(mutationRateText);
    mutationRateLabel.setLabelFor(mutationRateSpinner);

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(mutationRateLabel, constraints);
    mainPanel.add(mutationRateLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(mutationRateSpinner, constraints);
    mainPanel.add(mutationRateSpinner);
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @return/*  w  ww  . j  a  va 2s .  com*/
 */
private JPanel createGradientConfigurationPanel() {

    // create gradient config panel
    JPanel gradientConfigPanel = new JPanel(new GridBagLayout());
    gradientConfigPanel.setPreferredSize(new Dimension(100, 50));

    GridBagConstraints itemConstraint;

    // add gradient label
    {
        JLabel gradientLabel = new ResourceLabel(
                "plotter.configuration_dialog.color_scheme_dialog.gradient_preview");

        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.fill = GridBagConstraints.BOTH;
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.insets = new Insets(2, 2, 2, 2);

        gradientConfigPanel.add(gradientLabel, itemConstraint);
    }

    // add combobox panel
    {
        JPanel comboBoxPanel = new JPanel(new GridBagLayout());

        // gradient start panel
        {

            JPanel startGradientPanel = createStartGradientPanel();

            itemConstraint = new GridBagConstraints();
            itemConstraint.weightx = 1.0;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.anchor = GridBagConstraints.WEST;
            itemConstraint.fill = GridBagConstraints.HORIZONTAL;

            comboBoxPanel.add(startGradientPanel, itemConstraint);

        }

        // gradient end panel
        {

            JPanel endGradientPanel = createEndGradientPanel();

            itemConstraint = new GridBagConstraints();
            itemConstraint.weightx = 1.0;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.anchor = GridBagConstraints.EAST;
            itemConstraint.fill = GridBagConstraints.HORIZONTAL;

            comboBoxPanel.add(endGradientPanel, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 0.0;
        itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.insets = new Insets(2, 2, 2, 2);

        gradientConfigPanel.add(comboBoxPanel, itemConstraint);
    }

    // add 0.0 label
    {
        JLabel zeroLabel = new JLabel("0");

        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 0;
        itemConstraint.weighty = 0;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.insets = new Insets(2, 2, 2, 2);

        gradientConfigPanel.add(zeroLabel, itemConstraint);
    }

    // add gradient preview
    {
        preview = new GradientPreview(null);

        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.fill = GridBagConstraints.BOTH;
        itemConstraint.insets = new Insets(2, 2, 2, 2);

        gradientConfigPanel.add(preview, itemConstraint);

    }

    // add 1.0 label
    {
        JLabel zeroLabel = new JLabel("1");

        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 0;
        itemConstraint.weighty = 0;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.insets = new Insets(2, 2, 2, 2);
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;

        gradientConfigPanel.add(zeroLabel, itemConstraint);
    }

    return gradientConfigPanel;
}