Example usage for java.awt GridBagConstraints SOUTHWEST

List of usage examples for java.awt GridBagConstraints SOUTHWEST

Introduction

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

Prototype

int SOUTHWEST

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

Click Source Link

Document

Put the component at the bottom-left corner of its display area.

Usage

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

@SuppressWarnings("LeakingThisInConstructor")
public KeyValuePairPanel(int addCols, boolean widelist) {

    setOpaque(false);/*from  w  w  w  . j a  va 2 s.c  om*/

    ViewUtil.applyVerticalBoxLayout(this);
    kvpPanel = ViewUtil.getClearPanel();
    toolbar = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(toolbar);

    add(kvpPanel);
    add(toolbar);

    additionalColumns = addCols;
    keyKeyComponentMap = new HashMap<String, JLabel>();
    keyValueComponentMap = new HashMap<String, JPanel>();
    keyDetailComponentMap = new HashMap<String, JPanel>();
    keyExtraComponentsMap = new HashMap<String, JPanel[]>();

    columnConstraints = new ArrayList<GridBagConstraints>();
    keysInMoreSection = new ArrayList<String>();

    // Full-width detail component
    keyDetailConstraints = new GridBagConstraints();
    keyDetailConstraints.anchor = GridBagConstraints.SOUTHWEST;
    keyDetailConstraints.weightx = 1.0;
    keyDetailConstraints.fill = GridBagConstraints.BOTH;
    keyDetailConstraints.gridx = 0;
    keyDetailConstraints.gridy = 0;
    keyDetailConstraints.gridwidth = GridBagConstraints.REMAINDER;

    // Constraints for keys
    GridBagConstraints keyConstraints = new GridBagConstraints();
    keyConstraints.anchor = GridBagConstraints.SOUTHWEST;
    keyConstraints.fill = GridBagConstraints.BOTH;
    keyConstraints.weightx = 0;
    keyConstraints.gridx = 0;
    keyConstraints.gridy = 0;
    keyConstraints.ipadx = 5;

    // Constraints for values
    GridBagConstraints valueConstraints = new GridBagConstraints();
    valueConstraints.anchor = GridBagConstraints.SOUTHWEST;
    valueConstraints.fill = GridBagConstraints.BOTH;
    valueConstraints.weightx = widelist ? 0 : 1;
    valueConstraints.gridx = 1;
    valueConstraints.gridy = 0;
    valueConstraints.ipadx = 5;

    columnConstraints.add(keyConstraints);
    columnConstraints.add(valueConstraints);

    // Constraints for additional columns
    for (int i = 0; i < additionalColumns; i++) {
        GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.WEST;
        c.fill = GridBagConstraints.BOTH;

        // 1 iff widelist and last additional column
        c.weightx = widelist ? ((i == additionalColumns - 1) ? 1 : 0) : 0;
        c.gridx = i + columnConstraints.size();
        c.gridy = 0;
        columnConstraints.add(c);
    }

    GridBagLayout gbl = new GridBagLayout();
    kvpPanel.setLayout(gbl);
}