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.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @return/*from  w w  w .  j a  v  a 2s .c o  m*/
 */
private JPanel createStartGradientPanel() {
    GridBagConstraints itemConstraint;
    JPanel startGradientPanel = new JPanel(new GridBagLayout());

    // add gradient start label
    JLabel gradientStartLabel = new ResourceLabel(
            "plotter.configuration_dialog.color_scheme_dialog.gradient_start");
    {
        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 1;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        itemConstraint.insets = new Insets(0, 5, 5, 5);

        startGradientPanel.add(gradientStartLabel, itemConstraint);
    }

    // add gradient start color combobox
    {
        gradientStartColorComboBox = new JComboBox<Color>(gradientStartColorComboBoxModel);
        gradientStartLabel.setLabelFor(gradientStartColorComboBox);
        gradientStartColorComboBox.setPreferredSize(preferredGradientComboBoxSize);
        gradientStartColorComboBox.setRenderer(new ColorRGBComboBoxCellRenderer());
        gradientStartColorComboBox.setEditable(false);
        gradientStartColorComboBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                // set gradient start color at current active color scheme
                Color color = (Color) gradientStartColorComboBox.getSelectedItem();
                if (color != null && !adaptingModels) {

                    // enable apply and revert button
                    saveButton.setEnabled(true);
                    revertButton.setEnabled(true);

                    getCurrentActiveColorScheme().setGradientStartColor(ColorRGB.convertColorToColorRGB(color));
                }
                adaptGradientPlot();
                calculateGradientPreview();
            }

        });

        itemConstraint = new GridBagConstraints();
        itemConstraint.weightx = 1.0;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        // itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        // itemConstraint.insets = new Insets(0, 5, 5, 5);

        startGradientPanel.add(gradientStartColorComboBox, itemConstraint);
    }
    return startGradientPanel;
}

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

private void appendMutationAlgorithmComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {// w w  w .  j  a v a2 s. co  m

    mutationAlgorithmComboBox = new JComboBox<String>();
    for (MutationAlgorithmType mutationAlgorithmType : MutationAlgorithmType.values()) {
        mutationAlgorithmComboBox.addItem(mutationAlgorithmType.name());
    }
    mutationAlgorithmComboBox.setSelectedItem(MutationAlgorithmType.CONSERVATIVE.name());
    JLabel mutationAlgorithmNameLabel = new JLabel(mutationAlgorithmNameText);

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

From source file:pipeline.GUI_utils.ListOfPointsView.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//  w w w.  ja va2s . c o m
public void show() {
    if (frame != null)
        frame.toFront();
    if (table == null) {
        spreadsheetEngine = new DependencyEngine(new BasicEngineProvider());
        setupTableModel(points);
        silenceUpdates.incrementAndGet();
        table = new JXTablePerColumnFiltering(tableModel);

        table.setRolloverEnabled(true);
        // table.setDragEnabled(true);
        table.setFillsViewportHeight(false);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        table.setShowGrid(true);
        table.setShowHorizontalLines(true);
        table.setColumnSelectionAllowed(true);
        table.setRowSelectionAllowed(true);
        table.setColumnControlVisible(true);
        table.setHighlighters(new Highlighter[] { HighlighterFactory.createAlternateStriping() });

        table.addPropertyChangeListener("horizontalScrollEnabled", new PropertyChangeListener() {

            JViewport viewPort, filteringViewPort, columnDescViewPort;
            int lastX;

            ChangeListener scrollListener = new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    if (viewPort == null || filteringViewPort == null) {
                        return;
                    }
                    Point position = viewPort.getViewPosition();
                    if (position.x == lastX) {
                        return;
                    }
                    filteringViewPort.setViewPosition(position);
                    columnDescViewPort.setViewPosition(position);
                    lastX = position.x;
                }

            };

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (viewPort != null) {
                    viewPort.removeChangeListener(scrollListener);
                }
                if (evt.getNewValue().equals(true)) {
                    viewPort = getTableViewPort(table);
                    if (viewPort == null) {
                        return;
                    }
                    table.filteringTable.setHorizontalScrollEnabled(true);
                    table.tableForColumnDescriptions.setHorizontalScrollEnabled(true);
                    table.updateFilteringTableSetup();
                    filteringViewPort = getTableViewPort(table.filteringTable);
                    columnDescViewPort = getTableViewPort(table.tableForColumnDescriptions);
                    viewPort.addChangeListener(scrollListener);
                    scrollListener.stateChanged(null);
                } else {
                    table.filteringTable.setHorizontalScrollEnabled(false);
                    table.tableForColumnDescriptions.setHorizontalScrollEnabled(false);
                }
            }
        });

        modelForColumnDescriptions = new dataModelAllEditable(1, tableModel.getColumnCount());
        Vector<String> rowVector0 = (Vector<String>) modelForColumnDescriptions.getDataVector().get(0);
        for (int j = 0; j < tableModel.getColumnCount(); j++) {
            rowVector0.setElementAt(tableModel.getColumnName(j), j);
        }

        boolean done;
        do {
            done = true;
            for (TableColumn i : table.getColumns(true)) {
                TableColumnExt iCast = (TableColumnExt) i;
                if (iCast.getTitle().equals("Class") || iCast.getTitle().equals("c")
                        || iCast.getTitle().equals("t") || iCast.getTitle().equals("clusterID")
                        || iCast.getTitle().equals("userCell 2") || iCast.getTitle().equals("userCell 3")) {
                    if (iCast.isVisible()) {
                        iCast.setVisible(false);
                        done = false;
                        break;
                    }
                }
            }
        } while (!done);

        SwingUtilities.invokeLater(modelForColumnDescriptions::fireTableDataChanged);

        JScrollPane scrollPane = new JScrollPane(table);
        scrollPane.setPreferredSize(new Dimension(2000, 2000));

        updateColumnDescriptions();
        silenceUpdates.decrementAndGet();

        setSpreadsheetColumnEditorAndRenderer();

        tableForColumnDescriptions = new JXTable(modelForColumnDescriptions);
        table.tableForColumnDescriptions = tableForColumnDescriptions;

        JScrollPane jScrollPaneForNames = new JScrollPane(tableForColumnDescriptions);
        jScrollPaneForNames.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        JPanel controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());

        JButton createScatterPlotButton = new JButton("Scatter plot from selected columns");
        controlPanel.add(createScatterPlotButton);
        createScatterPlotButton.setActionCommand("Scatter plot from selected columns");
        createScatterPlotButton.addActionListener(this);

        realTimeUpdateCheckbox = new JCheckBox("Update display in real time");
        controlPanel.add(realTimeUpdateCheckbox);
        realTimeUpdateCheckbox.setActionCommand("Update display in real time");
        realTimeUpdateCheckbox.addActionListener(this);

        JButton forceUpdate = new JButton("Force display update");
        controlPanel.add(forceUpdate);
        forceUpdate.setActionCommand("Force display update");
        forceUpdate.addActionListener(this);

        JButton extendFormula = new JButton("Extend formula to column");
        controlPanel.add(extendFormula);
        extendFormula.setActionCommand("Extend formula to column");
        extendFormula.addActionListener(this);

        JButton saveFormulas = new JButton("Save user formulas...");
        saveFormulas.addActionListener(this);
        saveFormulas.setActionCommand("Save user formulas");
        controlPanel.add(saveFormulas);

        JButton reloadFormulas = new JButton("Reload user formulas...");
        reloadFormulas.addActionListener(this);
        reloadFormulas.setActionCommand("Reload user formulas");
        controlPanel.add(reloadFormulas);

        controlPanel.add(new JLabel("Color with:"));
        coloringComboBox = new JComboBox();
        controlPanel.add(coloringComboBox);
        DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) coloringComboBox.getModel();
        coloringComboBox.addActionListener(this);

        for (int i = 0; i < tableModel.getColumnCount(); i++) {
            comboBoxModel.addElement(tableModel.getColumnName(i));
        }

        JButton saveTableToFile = new JButton("Save table to file");
        controlPanel.add(saveTableToFile);
        saveTableToFile.setActionCommand("Save table to file");
        saveTableToFile.addActionListener(this);

        /*
        final JCheckBox useCalibration = new JCheckBox("Use calibration");
        useCalibration.addActionListener(e -> {
           if (points == null)
              return;
           boolean selected = useCalibration.isSelected();
           if (selected && !(points instanceof PluginIOCalibrable)) {
              Utils.displayMessage("Type " + points.getClass().getName() + " does not have calibration", true,
             LogLevel.ERROR);
              return;
           }
           PluginIOCalibrable calibrable = (PluginIOCalibrable) points;
           if (selected && (calibrable.getCalibration() == null)) {
              Utils.displayMessage("Calibration information is not present in the segmentation; one "
             + "way of adding it is to give the source image (with calibration) as an input "
             + "to the active contour plugin", true, LogLevel.ERROR);
              return;
           }
           float xyCalibration = selected ? ((float) calibrable.getCalibration().pixelWidth) : 0;
           float zCalibration = selected ? ((float) calibrable.getCalibration().pixelDepth) : 0;
           updateCalibration(xyCalibration, zCalibration);
        });
        PluginIOCalibrable calibrable = null;
        if (points instanceof PluginIOCalibrable)
           calibrable = (PluginIOCalibrable) points;
        boolean calibrationPresent = calibrable != null && calibrable.getCalibration() != null;
        useCalibration.setSelected(calibrationPresent);
        if (calibrationPresent) {
           updateCalibration((float) calibrable.getCalibration().pixelWidth,
          (float) calibrable.getCalibration().pixelDepth);
        }
        controlPanel.add(useCalibration);
        */

        frame = new JFrame(points.getName());
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        listener = new WindowListenerWeakRef(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                close();// So all references to data are nulled, to ensure garbage collection
            }

        });
        frame.addWindowListener(listener);

        frame.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 0;
        c.gridy = GridBagConstraints.RELATIVE;
        c.weighty = 0.75;
        c.weightx = 1.0;
        c.gridwidth = 1;
        c.gridheight = 1;

        frame.add(scrollPane, c);

        c.weighty = 0.0;
        JScrollPane scrollPane2 = new JScrollPane(table.filteringTable);
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setMinimumSize(new Dimension(1, 250));
        frame.add(scrollPane2, c);

        c.weighty = 0.0;
        jScrollPaneForNames.setMinimumSize(new Dimension(1, 40));
        jScrollPaneForNames.setMaximumSize(new Dimension(9999999, 40));
        frame.add(jScrollPaneForNames, c);

        c.weighty = 0.0;
        c.fill = GridBagConstraints.HORIZONTAL;
        controlPanel.setMinimumSize(new Dimension(1, 80));
        frame.add(controlPanel, c);

        table.setHorizontalScrollEnabled(true);
        table.updateFilteringTableSetup();

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        frame.setSize((int) (0.67 * width), height / 2);
        frame.setLocation((int) (0.33 * width), height / 2);
        frame.setVisible(true);
    }

    if ((tableUpdateThread == null) || (!tableUpdateThread.isAlive())) {
        tableUpdateThread = new Thread(() -> {
            try {
                checkForDirtiness();
            } catch (Exception e) {
                Utils.log("Exception in ListOfPointsView GUI update thread", LogLevel.ERROR);
                Utils.printStack(e);
            }
        }, "ListOfPointsView GUI update thread");

        tableUpdateThread.start();
    }
}

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

private void appendSelectionAlgorithmComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {// w w w .j  a  v a 2 s  .c om
    selectionAlgorithmComboBox = new JComboBox<String>();
    for (SelectionAlgorithmType selectionAlgorithmType : SelectionAlgorithmType.values()) {
        selectionAlgorithmComboBox.addItem(selectionAlgorithmType.name());
    }
    selectionAlgorithmComboBox.setSelectedItem(SelectionAlgorithmType.PROBABILISTIC.name());
    JLabel selectionAlgorithmNameLabel = new JLabel(selectionAlgorithmNameText);

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

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

private void appendSelectorComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {/* w ww  .j  a v  a2  s .  com*/
    selectorComboBox = new JComboBox<String>();
    for (SelectorType selectorType : SelectorType.values()) {
        selectorComboBox.addItem(selectorType.name());
    }
    selectorComboBox.setSelectedItem(SelectorType.TOURNAMENT.name());
    JLabel selectorNameLabel = new JLabel(selectorNameText);

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

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

/**
 * @return/*from  w ww .  ja  v  a 2s . co m*/
 */
private JPanel createColorCategoriesPanel() {
    JPanel categoryColorsConfigurationPanel = new JPanel(new GridBagLayout());
    categoryColorsConfigurationPanel.setPreferredSize(new Dimension(180, 200));

    GridBagConstraints itemConstraint = new GridBagConstraints();

    JLabel categoryColorsLabel = new ResourceLabel(
            "plotter.configuration_dialog.color_scheme_dialog.category_colors");
    {

        itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        itemConstraint.anchor = GridBagConstraints.WEST;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        itemConstraint.insets = new Insets(0, 5, 5, 5);
        itemConstraint.weightx = 1.0;

        categoryColorsConfigurationPanel.add(categoryColorsLabel, itemConstraint);
    }

    // add button panel
    {
        JPanel buttonPanel = new JPanel(new GridBagLayout());

        // remove scheme button
        {
            removeCategoryColorButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.remove_category_color_button") {

                private static final long serialVersionUID = 1L;

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

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(removeCategoryColorButton, itemConstraint);
        }

        {
            addCategoryButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.add_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    Color oldColor = Color.white;
                    Color newSchemeColor = createColorDialog(oldColor);
                    if (newSchemeColor != null && !newSchemeColor.equals(oldColor)) {
                        addColorAction(newSchemeColor);
                    }
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(addCategoryButton, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.anchor = GridBagConstraints.EAST;
        itemConstraint.insets = new Insets(0, 5, 5, 5);

        categoryColorsConfigurationPanel.add(buttonPanel, itemConstraint);
    }

    {

        JPanel categoryListPanel = new JPanel(new GridBagLayout());

        // add list of categorie colors
        {

            colorList = new JList<Color>(nominalColorListModel);
            categoryColorsLabel.setLabelFor(colorList);
            colorList.setCellRenderer(new ColorListCellRenderer());
            colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            MouseAdapter ma = new MouseAdapter() {

                private void myPopupEvent(MouseEvent e) {
                    int x = e.getX();
                    int y = e.getY();
                    JList<?> list = (JList<?>) e.getSource();
                    list.setSelectedIndex(list.locationToIndex(e.getPoint()));
                    Color selectedColor = (Color) list.getSelectedValue();
                    if (selectedColor == null) {
                        return;
                    }

                    removeMenuItem.setEnabled(nominalColorListModel.getSize() > 2);

                    popupMenu.show(list, x, y);
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }
            };

            colorList.addMouseListener(ma);
            colorList.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyPressed(KeyEvent e) {
                    int key = e.getKeyCode();
                    if (key == KeyEvent.VK_DELETE) {
                        if (nominalColorListModel.getSize() > 2) {
                            removeSelectedColorAction();
                        }
                    }
                    if (key == KeyEvent.VK_F2) {
                        replaceSelectedColorAction();
                    }
                    if (key == KeyEvent.VK_UP && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorUpAction();
                    }
                    if (key == KeyEvent.VK_DOWN && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorDownAction();
                    }
                }
            });

            colorListScrollPane = new JScrollPane(colorList);
            colorListScrollPane.setPreferredSize(new Dimension(170, 200));
            colorListScrollPane.setMaximumSize(new Dimension(170, 200));
            colorListScrollPane.setMinimumSize(new Dimension(170, 180));
            colorListScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            colorListScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 0.0;
            itemConstraint.weighty = 0.5;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;

            categoryListPanel.add(colorListScrollPane, itemConstraint);
        }

        // add up/down button panel
        {

            JPanel upAndDownButtonPanel = new JPanel(new GridBagLayout());

            // add up button
            {
                JButton upButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_up") {

                            private static final long serialVersionUID = 1L;

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

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

                upAndDownButtonPanel.add(upButton, itemConstraint);
            }

            // add down button
            {
                JButton downButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_down") {

                            private static final long serialVersionUID = 1L;

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

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

                upAndDownButtonPanel.add(downButton, itemConstraint);
            }

            // add spacer panel
            {
                JPanel spacer = new JPanel();

                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 1;
                itemConstraint.fill = GridBagConstraints.VERTICAL;

                upAndDownButtonPanel.add(spacer, itemConstraint);

            }

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

            categoryListPanel.add(upAndDownButtonPanel, itemConstraint);

        }

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

        categoryColorsConfigurationPanel.add(categoryListPanel, itemConstraint);
    }

    return categoryColorsConfigurationPanel;
}

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

private void appendCompareToKnownSolutionCheckBox(GridBagLayout gridBagLayout, GridBagConstraints constraints,
        JPanel mainPanel) {/*  www  .ja  v  a  2  s.  co m*/
    compareToKnownSolutionCheckBox = new JCheckBox(compareToKnownSolutionText);

    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(compareToKnownSolutionCheckBox, constraints);
    mainPanel.add(compareToKnownSolutionCheckBox);

    boolean isSolutionKnown = doesSelectedCipherHaveKnownSolution();
    compareToKnownSolutionCheckBox.setEnabled(isSolutionKnown);
    compareToKnownSolutionCheckBox.setSelected(isSolutionKnown);
}

From source file:org.photovault.swingui.PhotoInfoEditor.java

private void addLabelTextRows(JLabel[] labels, JComponent[] textFields, GridBagLayout gridbag,
        Container container) {//from   w  w w.ja  v a 2  s .co m
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(2, 2, 2, 2);
    int numLabels = labels.length;

    for (int i = 0; i < numLabels; i++) {
        c.anchor = GridBagConstraints.EAST;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE; //reset to default
        c.weightx = 0.0; //reset to default
        gridbag.setConstraints(labels[i], c);
        container.add(labels[i]);

        c.anchor = GridBagConstraints.WEST;
        c.gridwidth = GridBagConstraints.REMAINDER; //end row
        c.weightx = 1.0;
        gridbag.setConstraints(textFields[i], c);
        container.add(textFields[i]);
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java

/** 
 * Builds the UI component hosting the UI component used to modify 
 * the password./*from   w ww .  j  a  v  a2  s  .c  o m*/
 * 
 * @return See above.
 */
private JPanel buildPasswordPanel() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Registry reg = MetadataViewerAgent.getRegistry();
    String ldap = (String) reg.lookup(LookupNames.USER_AUTHENTICATION);
    if (ldap != null && ldap.length() > 0) {
        content.setBorder(BorderFactory.createTitledBorder("LDAP Authentication"));
        content.setLayout(new FlowLayout(FlowLayout.LEFT));
        content.add(new JLabel(ldap));
        return content;
    }
    content.setBorder(BorderFactory.createTitledBorder("Change Password"));

    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    if (MetadataViewerAgent.isAdministrator()) {
        content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        content.add(passwordNew, c);
    } else {
        content.add(UIUtilities.setTextFont(PASSWORD_OLD), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        content.add(oldPassword, c);
        c.gridy++;
        c.gridx = 0;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;
        c.weightx = 0.0;
        content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        content.add(passwordNew, c);
        c.gridy++;
        c.gridx = 0;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;
        c.weightx = 0.0;
        content.add(UIUtilities.setTextFont(PASSWORD_CONFIRMATION), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        content.add(passwordConfirm, c);
        c.gridy++;
        c.gridx = 0;
    }

    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(content);
    JPanel buttonPanel = UIUtilities.buildComponentPanel(passwordButton);
    buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(buttonPanel);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java

/** Builds and lays out the UI. */
void buildGUI() {
    removeAll();/*  w w  w  .ja v a  2s . c  o  m*/
    initComponents();
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.weightx = 1.0;
    add(buildContentPanel(), c);
    if (model.isUserOwner(model.getRefObject()) || MetadataViewerAgent.isAdministrator()) {
        c.gridy++;
        JPanel buttonPanel = UIUtilities.buildComponentPanel(saveButton);
        buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
        add(buttonPanel, c);
        c.gridy++;
        add(Box.createVerticalStrut(5), c);
        c.gridy++;
        add(buildPasswordPanel(), c);
    }
    ExperimenterData exp = (ExperimenterData) model.getRefObject();
    BufferedImage photo = model.getUserPhoto(exp.getId());
    if (photo == null)
        setUserPhoto(null);
    else
        setUserPhoto(photo);
    deletePhoto.setVisible(photo != null && canModifyPhoto());
}