Example usage for javax.swing JLabel setForeground

List of usage examples for javax.swing JLabel setForeground

Introduction

In this page you can find the example usage for javax.swing JLabel setForeground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
public void setForeground(Color fg) 

Source Link

Document

Sets the foreground color of this component.

Usage

From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java

public void mouseEntered(MouseEvent event) {
    if (event.getSource() instanceof JLabel) {
        JLabel lab = (JLabel) event.getSource();
        lab.setForeground(UIHelper.LIGHT_GREEN_COLOR);
    }//from w w w .j  a v a2 s.c  o m
}

From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java

public void mouseExited(MouseEvent event) {
    if (event.getSource() instanceof JLabel) {
        JLabel lab = (JLabel) event.getSource();
        lab.setForeground(UIHelper.DARK_GREEN_COLOR);
    }/*from w  w w  .  j  a  va2 s  .c  om*/
}

From source file:org.jannocessor.ui.RenderPreviewDialog.java

private void initialize() {
    logger.debug("Initializing UI...");
    DefaultSyntaxKit.initKit();// w w  w .  j  a  v  a 2s  .  c  o m

    JEditorPane.registerEditorKitForContentType("text/java_template", "org.jannocessor.syntax.JavaTemplateKit",
            getClass().getClassLoader());

    JEditorPane.registerEditorKitForContentType("text/java_output", "org.jannocessor.syntax.JavaOutputKit",
            getClass().getClassLoader());

    setTitle("JAnnocessor - Java Annotation Processor");
    setLayout(new BorderLayout(5, 5));

    listFiles();

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    double width = screenSize.getWidth() * 0.9;
    double height = screenSize.getHeight() * 0.8;

    // Font font = new Font("Courier New", Font.PLAIN, 14);

    input = createInput();
    JScrollPane scroll1 = new JScrollPane(input, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    input.setContentType("text/java_template");

    input.setText("");

    scroll1.setMinimumSize(new Dimension(200, 200));
    scroll1.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll1, BorderLayout.CENTER);

    output = Box.createVerticalBox();

    scroll2 = new JScrollPane(output, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll2.setMinimumSize(new Dimension(200, 200));
    scroll2.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll2, BorderLayout.EAST);

    combo = createCombo();

    combo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            load((File) combo.getSelectedItem());
        }
    });

    add(combo, BorderLayout.NORTH);
    JLabel help = new JLabel(
            " Choose a template from the drop-down box to edit it. Navigation: Alt + Left & Alt + Right; Refresh = F5, Close = Esc",
            JLabel.CENTER);

    help.setForeground(Color.WHITE);
    help.setBackground(Color.BLACK);
    help.setOpaque(true);
    help.setFont(new Font("Courier New", Font.BOLD, 14));
    add(help, BorderLayout.SOUTH);

    keyListener = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F5) {
                e.consume();
                processElements();
                refresh();
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                e.consume();
                dispose();
            } else if (e.getKeyCode() == KeyEvent.VK_LEFT && e.isAltDown()) {
                e.consume();
                moveBackward();
            } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && e.isAltDown()) {
                e.consume();
                moveForward();
            } else if (e.getKeyCode() == KeyEvent.VK_S && e.isControlDown()) {
                e.consume();
                save();
            } else if (e.getKeyCode() == KeyEvent.VK_I && e.isControlDown()) {
                e.consume();
                increase();
            } else if (e.getKeyCode() == KeyEvent.VK_D && e.isControlDown()) {
                e.consume();
                decrease();
            }
        }
    };

    input.addKeyListener(keyListener);
    combo.addKeyListener(keyListener);

    setActive(0);

    pack();
    setModal(true);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    input.requestFocus();
    logger.debug("Initialized UI.");
}

From source file:org.jas.dnd.DragTooltipDialog.java

private DynamicPanel getDynamicPanel(IconType type, List<?> list) {
    if (list == null || list.isEmpty()) {
        return null;
    }//from  w  w  w .  j  av a2 s  . com

    JPanel dynamicPanel = null;
    JLabel dynamicText = null;

    String text = list.isEmpty() ? null : (list.size()) + " " + (type == null ? "ERROR" : type.getText());
    if (list.size() == 1) {
        text = list.get(0) instanceof File ? ((File) list.get(0)).getName() : list.get(0).toString();
    }

    dynamicText = new JLabel(text);
    dynamicText.setForeground(Color.WHITE);
    FontMetrics fontMetrics = dynamicText.getFontMetrics(dynamicText.getFont());
    int width = fontMetrics.stringWidth(dynamicText.getText()) + DEFAULT_MIN_FONT_WIDTH;
    int realHeight = ROW_HEIGHT;
    String longestText = "";
    while (text.contains("<br>")) {
        text = text.substring(text.indexOf("<br>") + DEFAULT_MIN_FONT_WIDTH);
        if (text.length() > longestText.length()) {
            longestText = text;
        }
        realHeight += ROW_HEIGHT;
    }
    if (!longestText.isEmpty()) {
        width = fontMetrics.stringWidth(longestText) + DEFAULT_MIN_FONT_WIDTH;
    }
    dynamicPanel = new JPanel();
    dynamicPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    dynamicPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, realHeight));
    dynamicPanel.setMinimumSize(new Dimension(0, realHeight));
    dynamicPanel.setPreferredSize(new Dimension(100, realHeight));
    dynamicPanel.setSize(new Dimension(100, realHeight));
    if (type != null) {
        dynamicPanel.add(getDynamicIcon(type), null);
        JPanel spacer = new JPanel();
        Dimension d = new Dimension(SPACER_WIDTH, SPACER_WIDTH);
        width += SPACER_WIDTH;

        spacer.setSize(d);
        spacer.setMinimumSize(d);
        spacer.setMaximumSize(d);
        spacer.setPreferredSize(d);
        dynamicPanel.add(spacer);
        width += type.width;
    }
    dynamicPanel.add(dynamicText);
    return new DynamicPanel(dynamicPanel, width, realHeight);
}

From source file:org.languagetool.gui.ConfigurationDialog.java

public boolean show(List<Rule> rules) {
    configChanged = false;/*from w  w w .  j a v a2s.com*/
    if (original != null) {
        config.restoreState(original);
    }
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));
    // close dialog when user presses Escape key:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    configurableRules.clear();

    Language lang = config.getLanguage();
    if (lang == null) {
        lang = Languages.getLanguageForLocale(Locale.getDefault());
    }

    String specialTabNames[] = config.getSpecialTabNames();
    int numConfigTrees = 2 + specialTabNames.length;
    configTree = new JTree[numConfigTrees];
    JPanel checkBoxPanel[] = new JPanel[numConfigTrees];
    DefaultMutableTreeNode rootNode;
    GridBagConstraints cons;

    for (int i = 0; i < numConfigTrees; i++) {
        checkBoxPanel[i] = new JPanel();
        cons = new GridBagConstraints();
        checkBoxPanel[i].setLayout(new GridBagLayout());
        cons.anchor = GridBagConstraints.NORTHWEST;
        cons.gridx = 0;
        cons.weightx = 1.0;
        cons.weighty = 1.0;
        cons.fill = GridBagConstraints.HORIZONTAL;
        Collections.sort(rules, new CategoryComparator());
        if (i == 0) {
            rootNode = createTree(rules, false, null); //  grammar options
        } else if (i == 1) {
            rootNode = createTree(rules, true, null); //  Style options
        } else {
            rootNode = createTree(rules, true, specialTabNames[i - 2]); //  Special tab options
        }
        configTree[i] = new JTree(getTreeModel(rootNode));

        configTree[i].applyComponentOrientation(ComponentOrientation.getOrientation(lang.getLocale()));

        configTree[i].setRootVisible(false);
        configTree[i].setEditable(false);
        configTree[i].setCellRenderer(new CheckBoxTreeCellRenderer());
        TreeListener.install(configTree[i]);
        checkBoxPanel[i].add(configTree[i], cons);
        configTree[i].addMouseListener(getMouseAdapter());
    }

    JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOffice) {
        createNonOfficeElements(cons, portPanel);
    } else {
        createOfficeElements(cons, portPanel);
    }

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    JTabbedPane tabpane = new JTabbedPane();

    JPanel jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);

    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getMotherTonguePanel(cons), cons);

    if (insideOffice) {
        cons.gridy += 3;
    } else {
        cons.gridy++;
    }
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getNgramPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getWord2VecPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(portPanel, cons);
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.WEST;
    for (JPanel extra : extraPanels) {
        //in case it wasn't in a containment hierarchy when user changed L&F
        SwingUtilities.updateComponentTreeUI(extra);
        cons.gridy++;
        jPane.add(extra, cons);
    }

    cons.gridy++;
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1.0f;
    jPane.add(new JPanel(), cons);

    tabpane.addTab(messages.getString("guiGeneral"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[0]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(0), cons);

    tabpane.addTab(messages.getString("guiGrammarRules"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[1]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(1), cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.weightx = 5.0f;
    cons.weighty = 5.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(new JScrollPane(getSpecialRuleValuePanel()), cons);

    tabpane.addTab(messages.getString("guiStyleRules"), jPane);

    for (int i = 0; i < specialTabNames.length; i++) {
        jPane = new JPanel();
        jPane.setLayout(new GridBagLayout());
        cons = new GridBagConstraints();
        cons.insets = new Insets(4, 4, 4, 4);
        cons.gridx = 0;
        cons.gridy = 0;
        cons.weightx = 10.0f;
        cons.weighty = 10.0f;
        cons.fill = GridBagConstraints.BOTH;
        jPane.add(new JScrollPane(checkBoxPanel[i + 2]), cons);
        cons.weightx = 0.0f;
        cons.weighty = 0.0f;

        cons.gridx = 0;
        cons.gridy++;
        cons.fill = GridBagConstraints.NONE;
        cons.anchor = GridBagConstraints.LINE_END;
        jPane.add(getTreeButtonPanel(i + 2), cons);

        tabpane.addTab(specialTabNames[i], jPane);
    }

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    if (insideOffice) {
        JLabel versionText = new JLabel(messages.getString("guiUColorHint"));
        versionText.setForeground(Color.blue);
        jPane.add(versionText, cons);
        cons.gridy++;
    }

    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    cons.fill = GridBagConstraints.BOTH;

    jPane.add(new JScrollPane(getUnderlineColorPanel(rules)), cons);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(tabpane, cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    // center on screen:
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dialog.getSize();
    dialog.setLocation(screenSize.width / 2 - frameSize.width / 2,
            screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    //  add Color tab after dimension was set
    tabpane.addTab(messages.getString("guiUnderlineColor"), jPane);

    for (JPanel extra : this.extraPanels) {
        if (extra instanceof SavablePanel) {
            ((SavablePanel) extra).componentShowing();
        }
    }
    dialog.setVisible(true);
    return configChanged;
}

From source file:org.languagetool.gui.ConfigurationDialog.java

JPanel getUnderlineColorPanel(List<Rule> rules) {
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = 0;//w  ww .j  av  a2 s  . c  om
    cons.gridy = 0;
    cons.weightx = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;

    List<String> categories = new ArrayList<String>();
    for (Rule rule : rules) {
        String category = rule.getCategory().getName();
        boolean contain = false;
        for (String c : categories) {
            if (c.equals(category)) {
                contain = true;
                break;
            }
        }
        if (!contain) {
            categories.add(category);
        }
    }
    List<JLabel> categorieLabel = new ArrayList<JLabel>();
    List<JLabel> underlineLabel = new ArrayList<JLabel>();
    List<JButton> changeButton = new ArrayList<JButton>();
    List<JButton> defaultButton = new ArrayList<JButton>();
    for (int nCat = 0; nCat < categories.size(); nCat++) {
        categorieLabel.add(new JLabel(categories.get(nCat) + " "));
        underlineLabel.add(new JLabel(" \u2588\u2588\u2588 ")); // \u2587 is smaller
        underlineLabel.get(nCat).setForeground(config.getUnderlineColor(categories.get(nCat)));
        underlineLabel.get(nCat).setBackground(config.getUnderlineColor(categories.get(nCat)));
        JLabel uLabel = underlineLabel.get(nCat);
        String cLabel = categories.get(nCat);
        panel.add(categorieLabel.get(nCat), cons);
        cons.gridx++;
        panel.add(underlineLabel.get(nCat), cons);

        changeButton.add(new JButton(messages.getString("guiUColorChange")));
        changeButton.get(nCat).addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Color oldColor = uLabel.getForeground();
                Color newColor = JColorChooser.showDialog(null, messages.getString("guiUColorDialogHeader"),
                        oldColor);
                if (newColor != null && newColor != oldColor) {
                    uLabel.setForeground(newColor);
                    config.setUnderlineColor(cLabel, newColor);
                }
            }
        });
        cons.gridx++;
        panel.add(changeButton.get(nCat), cons);

        defaultButton.add(new JButton(messages.getString("guiUColorDefault")));
        defaultButton.get(nCat).addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                config.setDefaultUnderlineColor(cLabel);
                uLabel.setForeground(config.getUnderlineColor(cLabel));
            }
        });
        cons.gridx++;
        panel.add(defaultButton.get(nCat), cons);
        cons.gridx = 0;
        cons.gridy++;
    }
    return panel;
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected JComponent buildFooter() {
    JLabel label = new JLabel(NuxeoLauncherGUI.getMessage("footer.label", new DateTime().toString("Y")));
    label.setForeground(Color.WHITE);
    label.setPreferredSize(new Dimension(470, 16));
    label.setFont(new Font(label.getFont().getName(), label.getFont().getStyle(), 9));
    label.setHorizontalAlignment(SwingConstants.CENTER);
    return label;
}

From source file:org.nuxeo.launcher.sync.NuxeoSyncFrame.java

protected Component buildSyncPanel() {
    syncPanel = new JPanel();
    syncPanel.setBackground(new Color(55, 55, 55));
    syncPanel.setForeground(Color.WHITE);
    syncPanel.setLayout(new GridBagLayout());

    JLabel l = new JLabel("Server IP", SwingConstants.TRAILING);
    l.setForeground(Color.WHITE);
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1.0;/*from  www  . j a  v  a 2  s. c o  m*/
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(0, 0, 0, 0);
    syncPanel.add(l, c);
    syncServerIpTextField = new JTextField(10);
    l.setLabelFor(syncServerIpTextField);
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.WEST;

    syncPanel.add(syncServerIpTextField, c);

    l = new JLabel("Port", SwingConstants.TRAILING);
    l.setForeground(Color.WHITE);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.EAST;

    syncPanel.add(l, c);
    syncPortTextField = new JTextField(10);
    l.setLabelFor(syncPortTextField);
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.WEST;
    syncPanel.add(syncPortTextField, c);

    l = new JLabel("Login", SwingConstants.TRAILING);
    l.setForeground(Color.WHITE);
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.EAST;

    syncPanel.add(l, c);
    syncLoginTextField = new JTextField(10);
    l.setLabelFor(syncLoginTextField);
    c.gridx = 1;
    c.gridy = 3;
    c.anchor = GridBagConstraints.WEST;

    syncPanel.add(syncLoginTextField, c);

    l = new JLabel("Password", SwingConstants.TRAILING);
    l.setForeground(Color.WHITE);
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.EAST;

    syncPanel.add(l, c);
    syncPasswordField = new JPasswordField(10);
    l.setLabelFor(syncPasswordField);
    c.gridx = 1;
    c.gridy = 4;
    c.anchor = GridBagConstraints.WEST;
    syncPanel.add(syncPasswordField, c);

    syncButton = new JButton();
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    c.insets = new Insets(10, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    // set the action to the button
    synchronizeAction = createSyncAction();
    syncButton.setAction(synchronizeAction);
    syncButton.setText("Synchronize");

    updateSyncButton();

    syncPanel.add(syncButton, c);

    errorMessageLabel = new JLabel("", SwingConstants.TRAILING);
    errorMessageLabel.setForeground(Color.RED);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(10, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    syncPanel.add(errorMessageLabel, c);
    return syncPanel;
}

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

/**
 * Lays out the plate fields./*from   www.j  av a2  s  .  c o  m*/
 * 
 * @param plate The plate to handle.
 * @return See above.
 */
private JPanel layoutPlateContent(PlateData plate) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();
    String v = plate.getPlateType();
    JLabel value;
    if (v != null && v.trim().length() > 0) {
        l = UIUtilities.setTextFont(EditorUtil.TYPE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setFont(font.deriveFont(font.getStyle(), size));
        value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
        value.setText(v);
        components.put(l, value);
    }
    l = UIUtilities.setTextFont(EditorUtil.EXTERNAL_IDENTIFIER, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = plate.getExternalIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    l = UIUtilities.setTextFont(EditorUtil.STATUS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = plate.getStatus();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    layoutComponents(content, components);
    return content;
}

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

/**
 * Lays out the well fields./*from  ww  w . j a v a 2 s . c om*/
 * 
 * @param well The well to handle.
 * @return See above.
 */
private JPanel layoutWellContent(WellData well) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();
    String v = well.getWellType();
    JLabel value;
    if (v != null && v.trim().length() > 0) {
        l = UIUtilities.setTextFont(EditorUtil.TYPE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setFont(font.deriveFont(font.getStyle(), size));
        value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
        value.setText(v);
        components.put(l, value);
    }
    l = UIUtilities.setTextFont(EditorUtil.EXTERNAL_DESCRIPTION, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = well.getExternalDescription();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    l = UIUtilities.setTextFont(EditorUtil.STATUS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = well.getStatus();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    layoutComponents(content, components);
    return content;
}