Example usage for javax.swing JComponent setBackground

List of usage examples for javax.swing JComponent setBackground

Introduction

In this page you can find the example usage for javax.swing JComponent setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java

private void markFieldInHistoricalView(CollectableGenericObjectWithDependants clctlowdCurrent,
        String sFieldName, CollectableField clctfShown) {
    if (clctlowdCurrent != null) {
        final CollectableField clctf = clctlowdCurrent.getField(sFieldName);
        if (!clctfShown.equals(clctf)) {
            final Collection<CollectableComponent> collclctcomp = layoutrootDetails
                    .getCollectableComponentsFor(sFieldName);
            if (!collclctcomp.isEmpty()) {
                final CollectableComponent clctcomp = collclctcomp.iterator().next();
                final JComponent compFocussable = clctcomp.getFocusableComponent();
                String initialToolTip = (String) compFocussable.getClientProperty("initialToolTip");
                if (initialToolTip == null) {
                    initialToolTip = StringUtils.emptyIfNull(compFocussable.getToolTipText());
                    compFocussable.putClientProperty("initialToolTip", initialToolTip);
                }//  w  ww . j  a va2 s .c  om
                if (clctcomp instanceof CollectableComboBox) {
                    CollectableComboBox clctcmbx = (CollectableComboBox) clctcomp;
                    clctcmbx.getJComboBox().setRenderer(clctcmbx.new CollectableFieldRenderer() {

                        @Override
                        protected void paintComponent(Graphics g) {
                            setBackground(colorHistoricalChanged);
                            super.paintComponent(g);
                        }
                    });
                } else
                    compFocussable.setBackground(colorHistoricalChanged);
                final String sToolTip = getSpringLocaleDelegate().getMessage("GenericObjectCollectController.4",
                        "{0} [Ge\u00e4ndert; aktueller Wert: \"{1}\"]", initialToolTip, clctf.toString());
                compFocussable.setToolTipText(sToolTip);
                clctcomp.getJComponent().setToolTipText(sToolTip);
                // todo: mark fields which are not tracked in logbook?
            }
        }
    }
}

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

/**
 * Builds the panel hosting the user's details.
 * //w  w w .  ja  va  2  s  .com
 * @return See above.
 */
private JPanel buildContentPanel() {
    ExperimenterData user = (ExperimenterData) model.getRefObject();
    boolean editable = model.isUserOwner(user);
    if (!editable)
        editable = MetadataViewerAgent.isAdministrator();
    details = EditorUtil.convertExperimenter(user);
    JPanel content = new JPanel();
    content.setBorder(BorderFactory.createTitledBorder("User"));
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Entry<String, String> entry;
    Iterator<Entry<String, String>> i = details.entrySet().iterator();
    JComponent label;
    JTextField area;
    String key, value;
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    //Add log in name but cannot edit.
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;//end row
    c.fill = GridBagConstraints.HORIZONTAL;
    content.add(buildProfileCanvas(), c);
    c.gridy++;
    c.gridx = 0;
    label = EditorUtil.getLabel(EditorUtil.DISPLAY_NAME, true);
    label.setBackground(UIUtilities.BACKGROUND_COLOR);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;//end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    loginArea.setText(user.getUserName());
    loginArea.setEnabled(false);
    loginArea.setEditable(false);
    if (MetadataViewerAgent.isAdministrator() && !model.isSystemUser(user.getId()) && !model.isSelf()) {
        loginArea.setEnabled(true);
        loginArea.getDocument().addDocumentListener(this);
    }
    content.add(loginArea, c);
    while (i.hasNext()) {
        ++c.gridy;
        c.gridx = 0;
        entry = i.next();
        key = entry.getKey();
        value = entry.getValue();
        label = EditorUtil.getLabel(key, EditorUtil.FIRST_NAME.equals(key) || EditorUtil.LAST_NAME.equals(key));
        area = new JTextField(value);
        area.setBackground(UIUtilities.BACKGROUND_COLOR);
        area.setEditable(editable);
        area.setEnabled(editable);
        if (editable)
            area.getDocument().addDocumentListener(this);
        items.put(key, area);
        label.setBackground(UIUtilities.BACKGROUND_COLOR);
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;//reset to default
        c.weightx = 0.0;
        content.add(label, c);
        c.gridx++;
        content.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;//end row
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        content.add(area, c);
    }
    c.gridx = 0;
    c.gridy++;
    label = EditorUtil.getLabel(EditorUtil.DEFAULT_GROUP, false);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    content.add(groupsBox, c);
    c.gridy++;
    content.add(permissionsPane, c);
    c.gridx = 0;
    c.gridy++;
    label = EditorUtil.getLabel(EditorUtil.GROUP_OWNER, false);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE; //reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.NONE;
    c.weightx = 1.0;
    content.add(ownerBox, c);
    if (activeBox.isVisible()) {
        c.gridx = 0;
        c.gridy++;
        label = EditorUtil.getLabel(EditorUtil.ACTIVE, false);
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;
        c.weightx = 0.0;
        content.add(label, c);
        c.gridx++;
        content.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.NONE;
        c.weightx = 1.0;
        content.add(activeBox, c);
    }
    if (adminBox.isVisible()) {
        c.gridx = 0;
        c.gridy++;
        label = EditorUtil.getLabel(EditorUtil.ADMINISTRATOR, false);
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;
        c.weightx = 0.0;
        content.add(label, c);
        c.gridx++;
        content.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.NONE;
        c.weightx = 1.0;
        content.add(adminBox, c);
    }
    c.gridx = 0;
    c.gridy++;
    content.add(Box.createHorizontalStrut(10), c);
    c.gridy++;
    label = UIUtilities.setTextFont(EditorUtil.MANDATORY_DESCRIPTION, Font.ITALIC);
    label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR);
    c.weightx = 0.0;
    content.add(label, c);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java

/** 
 * Iterates through the components and sets the background color.
 * /*w  w w  .  j  a  v  a2  s.  c o m*/
 * @param c The component to handle
 * @param background The color to set.
 */
private void setComponentColor(JComponent c, Color background) {
    c.setBackground(background);
    if (c.getComponentCount() > 0) {
        Component[] components = c.getComponents();
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof JComponent) {
                setComponentColor((JComponent) components[i], background);
            }
        }
    }
}

From source file:org.openmicroscopy.shoola.util.ui.search.SearchComponent.java

/**
 * Adds the specified component to the result display.
 * /*from  w w  w .  j  av  a 2  s  . c  o m*/
 * @param result The component to add.
 * @param clear Pass <code>true</code> to remove the previous components,
 *              <code>false</code> otherwise.
 */
public void addResult(JComponent result, boolean clear) {
    if (clear)
        resultPane.removeAll();
    if (result == null)
        return;
    resultPane.add(result);
    resultPane.add(new JSeparator());
    result.setBackground(UIUtilities.BACKGROUND_COLOR);
    revalidate();
    repaint();
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Sets the defaults for the specified area.
 * /* w  w w  . java  2s.c om*/
 * @param area The text area.
 */
public static void setTextAreaDefault(JComponent area) {
    if (area == null)
        return;
    area.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    //area.setForeground(STEELBLUE);
    area.setBackground(BACKGROUND);
    area.setOpaque(true);
    if (area instanceof JTextComponent)
        ((JTextComponent) area).setEditable(true);
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Creates a new label.//from www .  j a v a 2  s.  c om
 * 
 * @param type    The type of component to create. Default type is JLabel.
 * @param color The foreground color if not <code>null</code>.
 * @return See above.
 */
public static JComponent createComponent(Class type, Color color) {
    if (type == null)
        type = JLabel.class;
    JComponent comp = null;
    if (JLabel.class.equals(type))
        comp = new JLabel();
    else if (OMETextField.class.equals(type))
        comp = new OMETextField();
    else if (OMETextArea.class.equals(type))
        comp = new OMETextArea();
    else if (NumericalTextField.class.equals(type)) {
        comp = new NumericalTextField();
        ((NumericalTextField) comp).setHorizontalAlignment(JTextField.LEFT);
        ((NumericalTextField) comp).setNegativeAccepted(true);
        comp.setBorder(null);
    }

    if (comp == null)
        comp = new JLabel();
    comp.setBackground(BACKGROUND_COLOR);
    Font font = comp.getFont();
    comp.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));
    if (color != null)
        comp.setForeground(color);
    return comp;
}

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

public SearchableTablePanel(String pageName, String[] columnNames, Class[] columnClasses, int[] hiddenColumns,
        boolean allowSearch, boolean allowSort, int defaultRows, boolean allowPages,
        TableSelectionType selectionType, int defaultRowsRetrieved, DataRetriever<Object[]> retriever) {

    this.pageName = pageName;
    this.rowsPerPageX = defaultRows;
    this.defaultRowsRetrieved = defaultRowsRetrieved;

    this.retriever = retriever;
    this.hiddenColumns = hiddenColumns;
    table = new SortableTable() {
        @Override//from  ww  w .  j  a  v  a2  s.  c  o m
        public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            synchronized (SearchableTablePanel.this) {
                JComponent comp = (JComponent) super.prepareRenderer(renderer, row, col);

                // Even index, selected or not selected
                if (isRowToggled(TableModelWrapperUtils.getActualRowAt(this.getSortableTableModel(), row))) { //this.getActualRowAt(this.getSortedRowAt(row)))) {
                    comp.setBackground(new Color(178, 225, 92));
                } else if (isCellSelected(row, col)) {
                    //comp.setBackground(new Color(75, 149, 229));
                    comp.setBackground(SELECTED_COLOUR);
                } else if (selectedRows != null
                        && selectedRows.contains(TableModelWrapperUtils.getActualRowAt(getModel(), row))) {
                    //comp.setBackground(SELECTED_COLOUR);
                } else if (row % 2 == 0 && !isCellSelected(row, col)) {
                    comp.setBackground(Color.WHITE);
                } else {
                    comp.setBackground(DARK_COLOUR);
                }

                comp.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7));
                return comp;
            }
        }

        @Override
        public String getToolTipText(MouseEvent e) {
            return getToolTip(
                    TableModelWrapperUtils.getActualRowAt(table.getModel(), table.rowAtPoint(e.getPoint())));
        }
    };

    table.setToolTipText(""); //necessary to force check for tooltip text

    table.setClearSelectionOnTableDataChanges(true);
    table.setOptimized(true);
    table.setColumnAutoResizable(true);
    table.setAutoResort(false);
    table.setRowHeight(20);
    table.setSortable(allowSort);
    table.setSortingEnabled(allowSort);
    table.setFocusable(selectionType != TableSelectionType.DISABLED);
    //table.setCellSelectionEnabled(allowSelection);
    table.setCellSelectionEnabled(selectionType == TableSelectionType.CELL);
    table.setRowSelectionAllowed(selectionType == TableSelectionType.ROW);

    table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    //column chooser
    TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table);
    installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer());
    columnChooser = new ColumnChooser(table);
    installer.addTableHeaderPopupMenuCustomizer(columnChooser);

    AutoFilterTableHeader header = new AutoFilterTableHeader(table);
    header.setAutoFilterEnabled(true);
    header.setShowFilterIcon(true);
    header.setShowFilterName(true);
    table.setTableHeader(header);

    filterField = new QuickTableFilterField(model);

    if (allowPages) {
        filterField.setHintText("Search for anything on the page");
    } else {
        filterField.setHintText("Search for anything");
    }

    setLayout(new BorderLayout(3, 3));
    fieldPanel = ViewUtil.getClearPanel();

    if (allowSearch) {
        fieldPanel.add(filterField);
    }

    chooseColumnButton = new JButton("Columns");
    chooseColumnButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            columnChooser.showDialog();
        }
    });

    helpButton = ViewUtil.getHelpButton("About Variant List",
            "Variants are sorted first by DNA ID, then by position.  The list of variants within each page can be sorted by various fields by clicking the corresponding column name, but note that this will only sort the current page.");
    exportButton = new JButton("Export");
    exportButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                ExportTable.exportTable(table);
            } catch (Exception ex) {
                LOG.error("Error while exporting.", ex);
                DialogUtils.displayException("MedSavant",
                        "<HTML>A problem occurred while exporting.<BR>Make sure the output file is not already in use.</HTML>",
                        ex);
            }
        }
    });

    fieldPanel.add(helpButton);
    fieldPanel.add(chooseColumnButton);
    fieldPanel.add(exportButton);

    bottomPanel = ViewUtil.getClearPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));

    gotoFirst = niceButton();
    gotoPrevious = niceButton();
    gotoNext = niceButton();
    gotoLast = niceButton();

    gotoFirst.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.FIRST));
    gotoPrevious.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.PREVIOUS));
    gotoNext.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.NEXT));
    gotoLast.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LAST));

    gotoFirst.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToFirstPage();
        }
    });
    gotoPrevious.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToPreviousPage();
        }
    });
    gotoNext.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToNextPage();
        }
    });
    gotoLast.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToLastPage();
        }
    });

    pageText = new JTextField();
    ViewUtil.makeSmall(pageText);
    pageText.setColumns(5);
    pageText.setMaximumSize(new Dimension(50, 20));
    pageText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER) {
                try {
                    setPageNumber(Integer.parseInt(pageText.getText()));
                } catch (NumberFormatException ex) {
                    setPageNumber(0);
                }
            }
        }
    });

    amountLabel = new JLabel();
    ViewUtil.makeSmall(amountLabel);
    bottomPanel.add(amountLabel);

    pageLabel1 = new JLabel("Page ");
    ViewUtil.makeSmall(pageLabel1);
    pageLabel2 = new JLabel();
    ViewUtil.makeSmall(pageLabel2);

    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(gotoFirst);
    bottomPanel.add(gotoPrevious);
    strut(bottomPanel);
    bottomPanel.add(pageLabel1);
    bottomPanel.add(pageText);
    bottomPanel.add(pageLabel2);
    strut(bottomPanel);
    bottomPanel.add(gotoNext);
    bottomPanel.add(gotoLast);
    bottomPanel.add(Box.createHorizontalGlue());

    strut(bottomPanel);

    JLabel perpageL = new JLabel("Per page:");
    ViewUtil.makeSmall(perpageL);
    bottomPanel.add(perpageL);

    strut(bottomPanel);

    boolean hasDefaultRowsPerPage = true;
    if (rowsPerPageX == ROWSPERPAGE_1 || rowsPerPageX == ROWSPERPAGE_2 || rowsPerPageX == ROWSPERPAGE_3) {
        hasDefaultRowsPerPage = false;
    }
    ArrayList<Integer> rowsList = new ArrayList<Integer>();
    rowsList.add(ROWSPERPAGE_1);
    rowsList.add(ROWSPERPAGE_2);
    rowsList.add(ROWSPERPAGE_3);
    Integer[] finalList = new Integer[3];
    if (hasDefaultRowsPerPage) {
        rowsList.add(rowsPerPageX);
        Collections.sort(rowsList);
    }
    finalList = rowsList.toArray(finalList);

    rowsPerPageDropdown = new JComboBox(finalList);
    ViewUtil.makeSmall(rowsPerPageDropdown);
    rowsPerPageDropdown.setPrototypeDisplayValue(ROWSPERPAGE_3);
    if (hasDefaultRowsPerPage) {
        rowsPerPageDropdown.setSelectedIndex(rowsList.indexOf(rowsPerPageX));
    } else {
        rowsPerPageDropdown.setSelectedIndex(1);
    }
    rowsPerPageDropdown.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            int rowsPerPage = (Integer) cb.getSelectedItem();
            setNumRowsPerPage(rowsPerPage);
        }
    });
    rowsPerPageDropdown.setPreferredSize(new Dimension(100, 25));
    rowsPerPageDropdown.setMaximumSize(new Dimension(100, 25));
    bottomPanel.add(rowsPerPageDropdown);

    setTableModel(data, columnNames, columnClasses);

    JPanel tablePanel = new JPanel(new BorderLayout(3, 3));
    JScrollPane jsp = new JScrollPane(table);
    jsp.setBorder(null);
    tablePanel.add(jsp);

    if (allowSort) {
        add(fieldPanel, BorderLayout.NORTH);
    }

    if (allowPages) {
        add(bottomPanel, BorderLayout.SOUTH);
    }

    add(tablePanel, BorderLayout.CENTER);

    initEmpty();
}

From source file:tufts.vue.EditLibraryPanel.java

private void layoutConfig() {
    if (DEBUG.BOXES) {
        cui.setBorder(BorderFactory.createLineBorder(Color.green));
        this.setBorder(BorderFactory.createLineBorder(Color.red));
    }/*from w ww.  j a  v  a2 s .  c  om*/

    final GridBagConstraints gbc = new GridBagConstraints();
    final GridBagLayout gridbag = new GridBagLayout();

    setLayout(gridbag);

    // Set up common GBC config:

    gbc.insets = (Insets) tufts.vue.gui.GUI.WidgetInsets.clone();
    gbc.insets.bottom = 0;
    gbc.weightx = 1;
    gbc.weighty = 0;

    //-------------------------------------------------------
    // Add ConfigurationUI
    //-------------------------------------------------------

    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridy = 0;

    add(cui, gbc);

    //-------------------------------------------------------
    // Add Save button
    //-------------------------------------------------------

    gbc.gridwidth = 1;
    gbc.gridy = 1;
    gbc.ipadx = 15; // this actually makes the button wider
    gbc.anchor = GridBagConstraints.NORTHEAST;
    gbc.fill = GridBagConstraints.NONE;

    add(updateButton, gbc);

    //-------------------------------------------------------
    // Add a default vertical expander so above content
    // will float to top.
    //-------------------------------------------------------

    gbc.ipadx = 0;
    gbc.gridy = 2;
    gbc.weighty = 1; // this is the key for the expander to work (non-zero y-weight)
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    gbc.gridwidth = 0;

    final JComponent fill;

    if (DEBUG.BOXES) {
        fill = new JLabel(VueResources.getString("jlabel.fill"), JLabel.CENTER);
        fill.setBackground(Color.gray);
        fill.setOpaque(true);
    } else {
        fill = new JPanel();
    }

    add(fill, gbc);
}

From source file:tufts.vue.ui.InspectorPane.java

/** labels & values must be of same length */
private void addLabelTextRows(int starty, JLabel[] labels, JComponent[] values, Container gridBag,
        Font labelFace, Font fieldFace) {
    // Note that the resulting alignment ends up being somehow FONT dependent!
    // E.g., works great with Lucida Grand (MacOSX), but with system default,
    // if the field value is a wrapping JTextPane (thus gets taller as window
    // gets narrower), the first line of text rises slightly and is no longer
    // in line with it's label.

    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    c.weighty = 0;// w w w .  j  a va2s.  c om
    c.gridheight = 1;

    for (int i = 0; i < labels.length; i++) {

        //out("ALTR[" + i + "] label=" + GUI.name(labels[i]) + " value=" + GUI.name(values[i]));

        boolean centerLabelVertically = false;
        final JLabel label = labels[i];
        final JComponent field = values[i];

        if (labelFace != null)
            GUI.apply(labelFace, label);

        if (field instanceof JTextComponent) {
            if (field instanceof JTextField)
                centerLabelVertically = true;
            //                 JTextComponent textField = (JTextComponent) field;
            //                 editable = textField.isEditable();
            //                 if (field instanceof JTextArea) {
            //                     JTextArea textArea = (JTextArea) field;
            //                     c.gridheight = textArea.getRows();
            //                     } else if (field instanceof JTextField)
        } else {
            if (fieldFace != null)
                GUI.apply(fieldFace, field);
        }

        //-------------------------------------------------------
        // Add the field label
        //-------------------------------------------------------

        c.gridx = 0;
        c.gridy = starty++;
        c.insets = labelInsets;
        c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last in row
        c.fill = GridBagConstraints.NONE; // the label never grows
        if (centerLabelVertically)
            c.anchor = GridBagConstraints.EAST;
        else
            c.anchor = GridBagConstraints.NORTHEAST;
        c.weightx = 0.0; // do not expand
        gridBag.add(label, c);

        //-------------------------------------------------------
        // Add the field value
        //-------------------------------------------------------

        c.gridx = 1;
        c.gridwidth = GridBagConstraints.REMAINDER; // last in row
        c.fill = GridBagConstraints.HORIZONTAL;
        c.anchor = GridBagConstraints.CENTER;
        //c.anchor = GridBagConstraints.NORTH;
        c.insets = fieldInsets;
        c.weightx = 1.0; // field value expands horizontally to use all space
        gridBag.add(field, c);

    }

    // add a default vertical expander to take up extra space
    // (so the above stack isn't vertically centered if it
    // doesn't fill the space).

    c.weighty = 1;
    c.weightx = 1;
    c.gridx = 0;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    JComponent defaultExpander = new JPanel();
    defaultExpander.setPreferredSize(new Dimension(Short.MAX_VALUE, 1));
    if (DEBUG.BOXES) {
        defaultExpander.setOpaque(true);
        defaultExpander.setBackground(Color.red);
    } else
        defaultExpander.setOpaque(false);
    gridBag.add(defaultExpander, c);
}