Example usage for javax.swing JLabel getFont

List of usage examples for javax.swing JLabel getFont

Introduction

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

Prototype

@Transient
public Font getFont() 

Source Link

Document

Gets the font of this component.

Usage

From source file:org.foxbpm.engine.impl.diagramview.svg.SVGUtils.java

/**
 * ??????/* w  ww  .j a v a  2s  . com*/
 * 
 * @param font
 *            ?
 * @param text
 *            
 * @return 
 */
public final static int getTextWidth(Font font, String text) {
    JLabel label = new JLabel(text);
    label.setFont(font);
    FontMetrics metrics = label.getFontMetrics(label.getFont());
    return metrics.stringWidth(label.getText());
}

From source file:org.gtdfree.GTDFree.java

private Component getOverviewPane() {
    if (overview == null) {
        overview = new JPanel();
        overview.setLayout(new GridBagLayout());

        int row = 0;

        JLabel l = new JLabel(Messages.getString("GTDFree.OW.Workflow")); //$NON-NLS-1$
        l.setFont(l.getFont().deriveFont((float) (l.getFont().getSize() * 5.0 / 4.0)).deriveFont(Font.BOLD));
        overview.add(l, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, new Insets(18, 18, 7, 18), 0, 0));

        overview.add(/*w  w  w .  j av  a2 s .  c  om*/
                new OverviewTabPanel(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_collecting),
                        TAB_COLECT, Messages.getString("GTDFree.Collect")), //$NON-NLS-1$
                new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                        GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));
        overview.add(
                new OverviewTabPanel(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_processing),
                        TAB_PROCESS, Messages.getString("GTDFree.Process")), //$NON-NLS-1$
                new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                        GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));
        overview.add(
                new OverviewTabPanel(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_review),
                        TAB_ORGANIZE, Messages.getString("GTDFree.Organize")), //$NON-NLS-1$
                new GridBagConstraints(0, row++, 1, 1, 0, 0, GridBagConstraints.CENTER,
                        GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));
        overview.add(
                new OverviewTabPanel(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_queue_execute),
                        TAB_EXECUTE, Messages.getString("GTDFree.Execute")), //$NON-NLS-1$
                new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                        GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));

        l = new JLabel(Messages.getString("GTDFree.OW.Summary")); //$NON-NLS-1$
        l.setFont(l.getFont().deriveFont((float) (l.getFont().getSize() * 5.0 / 4.0)).deriveFont(Font.BOLD));
        overview.add(l, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, new Insets(14, 18, 7, 18), 0, 0));

        SummaryLabel sl = new SummaryLabel("inbucketCount") { //$NON-NLS-1$
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                tabbedPane.setSelectedIndex(TAB_PROCESS);
            }

            @Override
            void updateText(PropertyChangeEvent arg0) {
                if (getSummaryBean().getInbucketCount() > 0) {
                    label.setText(
                            getSummaryBean().getInbucketCount() + " " + Messages.getString("GTDFree.OW.Bucket") //$NON-NLS-1$//$NON-NLS-2$
                                    + " " + Messages.getString("GTDFree.OW.Process")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(true);
                } else {
                    label.setText(getSummaryBean().getInbucketCount() + " " //$NON-NLS-1$
                            + Messages.getString("GTDFree.OW.Bucket")); //$NON-NLS-1$
                    button.setVisible(false);
                }
            }
        };
        overview.add(sl, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));

        sl = new SummaryLabel("pastActions") { //$NON-NLS-1$
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                tabbedPane.setSelectedIndex(TAB_ORGANIZE);
                organizePane.openTicklerForPast();
            }

            @Override
            void updateText(PropertyChangeEvent arg0) {
                if (getSummaryBean().getPastActions() > 0) {
                    label.setText(
                            getSummaryBean().getPastActions() + " " + Messages.getString("GTDFree.OW.Reminder") //$NON-NLS-1$//$NON-NLS-2$
                                    + " " + Messages.getString("GTDFree.OW.Update")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(true);
                } else {
                    label.setText(getSummaryBean().getPastActions() + " " //$NON-NLS-1$
                            + Messages.getString("GTDFree.OW.Reminder")); //$NON-NLS-1$
                    button.setVisible(false);

                }
            }
        };
        overview.add(sl, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));

        sl = new SummaryLabel("todayActions") { //$NON-NLS-1$
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                tabbedPane.setSelectedIndex(TAB_ORGANIZE);
                organizePane.openTicklerForToday();
            }

            @Override
            void updateText(PropertyChangeEvent arg0) {
                if (getSummaryBean().getTodayActions() > 0) {
                    label.setText(
                            getSummaryBean().getTodayActions() + " " + Messages.getString("GTDFree.OW.Due") //$NON-NLS-1$//$NON-NLS-2$
                                    + " " + Messages.getString("GTDFree.OW.Tickler")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(true);
                } else {
                    label.setText(
                            getSummaryBean().getTodayActions() + " " + Messages.getString("GTDFree.OW.Due")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(false);

                }
            }
        };
        overview.add(sl, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));

        sl = new SummaryLabel("queueCount") { //$NON-NLS-1$
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                tabbedPane.setSelectedIndex(TAB_EXECUTE);
            }

            @Override
            void updateText(PropertyChangeEvent arg0) {
                if (getSummaryBean().getQueueCount() > 0) {
                    label.setText(
                            getSummaryBean().getQueueCount() + " " + Messages.getString("GTDFree.OW.Queue") //$NON-NLS-1$//$NON-NLS-2$
                                    + " " + Messages.getString("GTDFree.OW.Execute")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(true);
                } else {
                    label.setText(
                            getSummaryBean().getQueueCount() + " " + Messages.getString("GTDFree.OW.Queue")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(false);

                }
            }
        };
        overview.add(sl, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));

        sl = new SummaryLabel("mainCounts") { //$NON-NLS-1$
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                GTDFree.this.getActionMap().get("importDialog").actionPerformed(e); //$NON-NLS-1$
                engine.getGlobalProperties().putProperty("examplesImported", true); //$NON-NLS-1$
                updateText(new PropertyChangeEvent(this, "mainCounts", -1, 1)); //$NON-NLS-1$
            }

            @Override
            void updateText(PropertyChangeEvent arg0) {
                if (!getEngine().getGlobalProperties().getBoolean("examplesImported", false)) { //$NON-NLS-1$
                    label.setText(getSummaryBean().getOpenCount() + " " //$NON-NLS-1$
                            + Messages.getString("GTDFree.OW.Open.1") + " " + getSummaryBean().getTotalCount() //$NON-NLS-1$//$NON-NLS-2$
                            + " " + Messages.getString("GTDFree.OW.Open.2") + " " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                            + Messages.getString("GTDFree.OW.Import")); //$NON-NLS-1$
                    button.setVisible(true);
                } else {
                    label.setText(getSummaryBean().getOpenCount() + " " //$NON-NLS-1$
                            + Messages.getString("GTDFree.OW.Open.1") + " " + getSummaryBean().getTotalCount() //$NON-NLS-1$//$NON-NLS-2$
                            + " " + Messages.getString("GTDFree.OW.Open.2")); //$NON-NLS-1$ //$NON-NLS-2$
                    button.setVisible(false);

                }
            }
        };
        overview.add(sl, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 18, 4, 18), 0, 0));

        overview.add(new JPanel(), new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.WEST,
                GridBagConstraints.NONE, new Insets(0, 11, 0, 11), 0, 0));

    }

    return overview;
}

From source file:org.gtdfree.GTDFree.java

/**
 * This method initializes aboutDialog   
 *    //from www .j a  va2  s.  c  o  m
 * @return javax.swing.JDialog
 */
private JDialog getAboutDialog() {
    if (aboutDialog == null) {
        aboutDialog = new JDialog(getJFrame(), true);
        aboutDialog.setTitle(Messages.getString("GTDFree.About.Free")); //$NON-NLS-1$
        Image i = ApplicationHelper.loadImage(ApplicationHelper.icon_name_large_logo); //$NON-NLS-1$
        ImageIcon ii = new ImageIcon(i);

        JTabbedPane jtp = new JTabbedPane();

        JPanel jp = new JPanel();
        jp.setLayout(new GridBagLayout());
        JLabel jl = new JLabel("GTD-Free", ii, SwingConstants.CENTER); //$NON-NLS-1$
        jl.setIconTextGap(22);
        jl.setFont(jl.getFont().deriveFont((float) 24));
        jp.add(jl, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 11), 0, 0));
        String s = "Version " + ApplicationHelper.getVersion(); //$NON-NLS-1$
        jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 1, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 11, 4, 11), 0, 0));
        s = Messages.getString("GTDFree.About.DBType") //$NON-NLS-1$
                + getEngine().getGTDModel().getDataRepository().getDatabaseType();
        jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 2, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 2, 11), 0, 0));
        s = Messages.getString("GTDFree.About.DBloc") + getEngine().getDataFolder(); //$NON-NLS-1$
        jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 3, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 11, 4, 11), 0, 0));
        jp.add(new JLabel("Copyright  2008,2009 ikesan@users.sourceforge.net", SwingConstants.CENTER), //$NON-NLS-1$
                new GridBagConstraints(0, 4, 1, 1, 1, 0, GridBagConstraints.CENTER,
                        GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 11), 0, 0));
        jtp.addTab("About", jp); //$NON-NLS-1$

        jp = new JPanel();
        jp.setLayout(new GridBagLayout());
        TableModel tm = new AbstractTableModel() {
            private static final long serialVersionUID = -8449423008172417278L;
            private String[] props;

            private String[] getProperties() {
                if (props == null) {
                    props = System.getProperties().keySet().toArray(new String[System.getProperties().size()]);
                    Arrays.sort(props);
                }
                return props;
            }

            @Override
            public String getColumnName(int column) {
                switch (column) {
                case 0:
                    return Messages.getString("GTDFree.About.Prop"); //$NON-NLS-1$
                case 1:
                    return Messages.getString("GTDFree.About.Val"); //$NON-NLS-1$
                default:
                    return null;
                }
            }

            public int getColumnCount() {
                return 2;
            }

            public int getRowCount() {
                return getProperties().length;
            }

            public Object getValueAt(int rowIndex, int columnIndex) {
                switch (columnIndex) {
                case 0:
                    return getProperties()[rowIndex];
                case 1:
                    return System.getProperty(getProperties()[rowIndex]);
                default:
                    return null;
                }
            }
        };
        JTable jt = new JTable(tm);
        jp.add(new JScrollPane(jt), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0));
        jtp.addTab(Messages.getString("GTDFree.About.SysP"), jp); //$NON-NLS-1$

        jp = new JPanel();
        jp.setLayout(new GridBagLayout());
        JTextArea ta = new JTextArea();
        ta.setEditable(false);
        ta.setText(ApplicationHelper.loadLicense());
        ta.setCaretPosition(0);
        jp.add(new JScrollPane(ta), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0));
        jtp.addTab("License", jp); //$NON-NLS-1$

        aboutDialog.setContentPane(jtp);
        aboutDialog.setSize(550, 300);
        //aboutDialog.pack();
        aboutDialog.setLocationRelativeTo(getJFrame());
    }
    return aboutDialog;
}

From source file:org.intermine.install.swing.BuildProjectDialog.java

/**
 * Common initialisation: lays out the child components and wires up the necessary
 * event listeners./*from   w  ww.  j  a  v  a  2 s  .  c o  m*/
 */
private void init() {

    setName("Build Project Dialog");
    setTitle(Messages.getMessage("build.project.title"));

    releaseNumberLabel.setLabelFor(releaseNumberTextField);
    destinationLabel.setLabelFor(destinationTextField);

    Container cp = getContentPane();

    GridBagConstraints cons = GridBagHelper.setup(cp);

    JLabel infoLabel = new JLabel(Messages.getMessage("build.project.info.message"));
    infoLabel.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    cons.gridwidth = 2;
    cons.weightx = 1;
    cp.add(infoLabel, cons);

    JPanel startPolicyPanel = new JPanel();
    //        startPolicyPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    GridBagConstraints startPolicyPanelCons = GridBagHelper.setup(startPolicyPanel);
    startPolicyPanelCons.gridwidth = GridBagConstraints.REMAINDER;
    startPolicyPanel.add(startPolicyLabel, startPolicyPanelCons);

    startPolicyPanelCons.gridy++;
    startPolicyPanelCons.gridwidth = 2;
    buildDbRadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    startPolicyPanel.add(buildDbRadioButton, startPolicyPanelCons);

    startPolicyPanelCons.gridy++;
    restart1RadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    startPolicyPanel.add(restart1RadioButton, startPolicyPanelCons);

    //        startPolicyPanelCons.gridy++;
    //        restart2RadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    //        startPolicyPanel.add(restart2RadioButton, startPolicyPanelCons);
    //
    //        startPolicyPanelCons.gridy++;
    //        testRadioButton.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    //        startPolicyPanel.add(testRadioButton, startPolicyPanelCons);

    cons.gridy++;
    cp.add(startPolicyPanel, cons);

    JPanel userDBPanel = new JPanel();
    //        userDBPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    GridBagConstraints userDBCons = GridBagHelper.setup(userDBPanel);
    userDBPanel.setAlignmentY(LEFT_ALIGNMENT);
    //        cons.gridwidth = GridBagConstraints.REMAINDER;

    userDBPanel.add(userDBOptionsLabel, userDBCons);

    //        userDBCons.gridy++;
    //        nowriteUserDbRadio.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    //        userDBPanel.add(nowriteUserDbRadio, userDBCons);
    //
    //        userDBCons.gridy++;
    //        writeUserDbRadio.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    //        userDBPanel.add(writeUserDbRadio, userDBCons);
    //
    //        userDBCons.gridy++;
    //        overwriteUserDbRadio.setFont(infoLabel.getFont().deriveFont(Font.PLAIN));
    //        userDBPanel.add(overwriteUserDbRadio, userDBCons);
    //
    //        cons.gridy++;
    //        cp.add(userDBPanel, cons);

    cons.gridy++;
    cons.gridx = 0;
    cons.weightx = 0;
    cons.gridwidth = 1;
    cp.add(encodingLabel, cons);

    cons.gridx++;
    cons.weightx = 0.5;
    encodingDropdown = new JComboBox(encodings);
    cp.add(encodingDropdown, cons);
    //cp.add(encodingTextField, cons);

    //        cons.gridy++;
    //        cons.gridx = 0;
    //        cons.gridwidth = 3;
    //        cons.weightx = 1;
    //        cp.add(serverBackupCheckBox, cons);

    //        cons.gridy++;
    //        cons.gridx = 0;
    //        cons.weightx = 0;
    //        cons.gridwidth = 1;
    //        cp.add(destinationCheckBox, cons);

    //        cons.gridy++;
    //        cons.weightx = 0;
    //        cons.gridwidth = 1;
    //        cp.add(destinationLabel, cons);

    //        cons.gridx++;
    //        cons.weightx = 0.75;
    //        cons.gridwidth = 2;
    //        cp.add(destinationTextField, cons);

    cons.gridy++;
    cons.gridx = 0;
    cons.weightx = 0;
    cons.gridwidth = 1;
    cp.add(new JLabel(Messages.getMessage("build.project.dump.host")), cons);

    cons.gridx++;
    cons.weightx = 0.75;
    cons.gridwidth = 1;
    cp.add(hostTextField, cons);

    cons.gridy++;
    cons.gridx = 0;
    cons.weightx = 0;
    cons.gridwidth = 1;
    cp.add(new JLabel(Messages.getMessage("build.project.dump.prefix")), cons);

    cons.gridx++;
    cons.weightx = 0.75;
    cons.gridwidth = 1;
    cp.add(prefixTextField, cons);

    cons.gridy++;
    cons.gridx = 0;
    cp.add(releaseNumberCheckBox, cons);

    //        cons.gridy++;
    //        cons.weightx = 0;
    //        cons.gridwidth = 1;
    //        cp.add(releaseNumberLabel, cons);

    cons.gridx++;
    cons.weightx = 0.5;
    cp.add(releaseNumberTextField, cons);

    cons.gridy++;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridx = 0;
    cons.weightx = 1;
    cp.add(new ButtonPanel(buildAction, new CancelAction()), cons);

    // encodingTextField.setText("SQL_ASCII");
    //        releaseNumberLabel.setEnabled(false);
    releaseNumberTextField.setEnabled(false);
    //        destinationLabel.setEnabled(false);
    //        destinationTextField.setEnabled(false);

    /**
    * Create Button group for userdb radio buttons
    * @serial
    */
    ButtonGroup userDBButtonGroup = new ButtonGroup();
    userDBButtonGroup.add(writeUserDbRadio);
    userDBButtonGroup.add(overwriteUserDbRadio);
    userDBButtonGroup.add(nowriteUserDbRadio);

    ButtonGroup startPolicyGroup = new ButtonGroup();
    startPolicyGroup.add(restart1RadioButton);
    startPolicyGroup.add(restart2RadioButton);
    startPolicyGroup.add(buildDbRadioButton);
    startPolicyGroup.add(testRadioButton);

    releaseNumberCheckBox.addActionListener(
            new LinkedFieldListener(releaseNumberCheckBox, releaseNumberLabel, releaseNumberTextField));
    destinationCheckBox.addActionListener(
            new LinkedFieldListener(destinationCheckBox, destinationLabel, destinationTextField));

    DocumentListener requiredTextListener = new RequiredTextListener();
    releaseNumberTextField.getDocument().addDocumentListener(requiredTextListener);
    //        destinationTextField.getDocument().addDocumentListener(requiredTextListener);
    hostTextField.getDocument().addDocumentListener(requiredTextListener);
    prefixTextField.getDocument().addDocumentListener(requiredTextListener);

    hostTextField.setToolTipText(Messages.getMessage("build.project.dump.host.tooltip"));
    hostTextField.setText("localhost");

    pack();

    progressDialog = new SystemProcessProgressDialog(this);
    progressDialog.setModalityType(ModalityType.APPLICATION_MODAL);
    progressDialog.setTitle(Messages.getMessage("build.project.title"));
    progressDialog.setInformationLabel(Messages.getMessage("build.project.message"));
}

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  a  v a 2 s. co m*/

    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.javaswift.cloudie.CloudiePanel.java

private List<LabelComponentPanel> buildMetaDataPanels(Map<String, Object> metadata) {
    List<LabelComponentPanel> panels = new ArrayList<LabelComponentPanel>();
    for (Map.Entry<String, Object> entry : metadata.entrySet()) {
        JLabel comp = new JLabel(String.valueOf(entry.getValue()));
        comp.setFont(comp.getFont().deriveFont(Font.PLAIN));
        panels.add(new LabelComponentPanel(entry.getKey(), comp));
    }/*from ww  w .j a va2 s.c om*/
    return panels;
}

From source file:org.jets3t.gui.skins.html.SkinnedLookAndFeel.java

public SkinnedLookAndFeel(Properties skinProperties, String itemName) {
    super();// w w  w. ja  v  a  2  s  .  c o m

    // Determine system defaults.
    JLabel defaultLabel = new JLabel();
    Color backgroundColor = defaultLabel.getBackground();
    Color textColor = defaultLabel.getForeground();
    Font font = defaultLabel.getFont();

    // Find skinning configurations.
    String backgroundColorValue = skinProperties.getProperty("backgroundColor", null);
    String textColorValue = skinProperties.getProperty("textColor", null);
    String fontValue = skinProperties.getProperty("font", null);

    // Apply skinning configurations.
    if (backgroundColorValue != null) {
        Color color = Color.decode(backgroundColorValue);
        if (color == null) {
            log.error("Unable to set background color with value: " + backgroundColorValue);
        } else {
            backgroundColor = color;
        }
    }
    if (textColorValue != null) {
        Color color = Color.decode(textColorValue);
        if (color == null) {
            log.error("Unable to set text color with value: " + textColorValue);
        } else {
            textColor = color;
        }
    }
    if (fontValue != null) {
        Font myFont = Font.decode(fontValue);
        if (myFont == null) {
            log.error("Unable to set font with value: " + fontValue);
        } else {
            font = myFont;
        }
    }

    // Update metal theme with configured display properties.
    SkinnedMetalTheme skinnedTheme = new SkinnedMetalTheme(new ColorUIResource(backgroundColor),
            new ColorUIResource(textColor), new FontUIResource(font));
    MetalLookAndFeel.setCurrentTheme(skinnedTheme);
}

From source file:org.neo4j.desktop.ui.DatabaseStatus.java

private static JPanel createStartedStatusDisplay(DesktopModel model, Environment environment) {
    final JLabel link = new JLabel("http://localhost:7474/");

    model.register(new DesktopModelListener() {
        @Override//from www.  j  av  a  2  s .com
        public void desktopModelChanged(DesktopModel model) {
            link.setText("http://localhost:" + model.getServerPort() + "/");
        }
    });

    link.setFont(Components.underlined(link.getFont()));
    link.addMouseListener(new OpenBrowserMouseListener(link, environment));

    return createStatusDisplay(STARTED_COLOR, new JLabel("Neo4j is ready. Browse to "), link);
}

From source file:org.ngrinder.recorder.ui.AboutDialog.java

private JLabel getAppName() {
    JLabel appName = new JLabel("nGrinder Recorder");
    appName.setAlignmentX(CENTER_ALIGNMENT);
    appName.setFont(appName.getFont().deriveFont(Font.BOLD, 12.0f));

    return appName;
}

From source file:org.nuclos.client.ui.JInfoTabbedPane.java

private void setTabComponent(String text, int index) {
    JLabel tabComponent = new JLabel(text);
    int height = tabComponent.getFontMetrics(tabComponent.getFont()).getHeight();
    int width = tabComponent.getFontMetrics(tabComponent.getFont()).stringWidth(text + " (>999)");
    tabComponent.setPreferredSize(new Dimension(width, height));
    tabComponent.setHorizontalAlignment(SwingConstants.CENTER);
    setTabComponentAt(index, tabComponent);
}