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:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Updates the chat message panel in the Swing event thread
 *//*from   w  w w  .  ja  v  a 2  s .  c  o m*/
public void updateChatMessagePanel() {
    // Ensure that we operate in the Swing event thread
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateChatMessagePanel();
            }
        });
        return;
    }

    // Only enable send-function when there is chat data, and hence a target
    addBtn.setEnabled(true);
    messageText.setEditable(true);

    // Remove all components from the messages panel
    messagesPanel.removeAll();

    Insets insets = new Insets(0, 2, 2, 2);
    Insets insets2 = new Insets(6, 2, 0, 2);

    // if (chatData != null && chatData.getMessageCount() > 0) {

    // First, add a filler component
    int y = 0;
    messagesPanel.add(new JLabel(""),
            new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0));

    // Add the messages
    long lastMessageTime = 0;

    long ownMMSI = MaritimeCloudUtils.toMmsi(EPD.getInstance().getMaritimeId());

    for (VOCTSARInfoMessage message : EPD.getInstance().getVoctHandler().getAdditionalInformationMsgs()) {

        boolean ownMessage = false;

        if (message.getSender() == ownMMSI) {
            ownMessage = true;
        }

        // EPD.getInstance().getIdentityHandler().getActor(mmsi)

        // Check if we need to add a time label
        if (message.getDate() - lastMessageTime > PRINT_DATE_INTERVAL) {

            JLabel dateLabel = new JLabel(String.format(ownMessage ? "Added %s" : "Received %s",
                    Formatter.formatShortDateTimeNoTz(new Date(message.getDate()))));
            dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN));
            dateLabel.setHorizontalAlignment(SwingConstants.CENTER);
            dateLabel.setForeground(Color.LIGHT_GRAY);
            messagesPanel.add(dateLabel,
                    new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0));
        }

        // Add a chat message field
        JPanel msg = new JPanel();
        msg.setBorder(new ChatMessageBorder(message, ownMessage));
        JLabel msgLabel = new ChatMessageLabel(message.getMessage(), ownMessage);
        msg.add(msgLabel);
        messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0));

        lastMessageTime = message.getDate();
    }

    // Scroll to the bottom
    validate();
    scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());
    messagesPanel.repaint();

    // } else if (chatData == null && noDataComponent != null) {
    // // The noDataComponent may e.g. be a message
    // messagesPanel.add(noDataComponent, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }
}

From source file:edu.ku.brc.specify.tasks.StatsTrackerTask.java

@Override
protected void showClosingFrame() {
    if (hasChanged) {
        ImageIcon img = IconManager.getIcon("SpecifySplash");

        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,150px", "f:p:g,2px,p"));
        pb.setDefaultDialogBorder();/*from  w  w w .  j a  v a2  s  .  com*/

        JLabel lbl = new JLabel(img);
        pb.add(lbl, cc.xyw(1, 1, 2));
        lbl = UIHelper.createI18NLabel("SPECIFY_SHUTDOWN", SwingConstants.CENTER);
        lbl.setFont(lbl.getFont().deriveFont(18.0f));
        pb.add(lbl, cc.xy(1, 3));

        progress = new JProgressBar(0, 100);
        pb.add(progress, cc.xy(2, 3));

        JFrame frame = new JFrame();
        frame.setUndecorated(true);
        frame.setContentPane(pb.getPanel());
        frame.pack();
        UIHelper.centerAndShow(frame);
    }
}

From source file:burp.BurpExtender.java

private void createTitle(String text, Container cont) {
    JLabel title = new JLabel(text);
    title.setForeground(new Color(229, 137, 0));
    Font f = title.getFont();
    title.setFont(new Font(f.getName(), Font.BOLD, f.getSize() + 2));
    callbacks.customizeUiComponent(title);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 0;/*w w w  .  j a v a 2 s .  com*/
    gbc.gridx = 0;
    gbc.insets = new Insets(8, 10, 0, 0);
    gbc.anchor = GridBagConstraints.WEST;
    cont.add(title, gbc);
}

From source file:com.sshtools.appframework.api.ui.SshToolsApplicationPanel.java

/**
 * Display something other that the normal blank screen so our component
 * looks pretty.//  w  w  w . j  av  a  2 s.com
 */
protected void showWelcomeScreen() {
    synchronized (getTreeLock()) {
        removeAll();
        setLayout(new BorderLayout());
        //         GradientPanel p = new GradientPanel(new BorderLayout());
        //         p.setBackground(Color.white);
        //         p.setBackground2(new Color(164, 228, 244));
        //         p.setForeground(Color.black);
        JPanel p = new JPanel(new BorderLayout());
        JLabel welcomeLabel = new JLabel("", JLabel.CENTER);
        welcomeLabel.setForeground(Color.white);
        welcomeLabel.setFont(welcomeLabel.getFont().deriveFont(72f).deriveFont(Font.BOLD + Font.ITALIC));
        welcomeLabel.setHorizontalAlignment(JLabel.RIGHT);
        p.add(welcomeLabel, BorderLayout.SOUTH);
        add(p, BorderLayout.CENTER);
        validate();
    }
}

From source file:com.diversityarrays.kdxplore.field.FieldViewPanel.java

public FieldViewPanel(PlotVisitList plotVisitList, Map<Integer, Trait> traitMap,
        SeparatorVisibilityOption visible, SimplePlotCellRenderer plotRenderer, Component... extras) {
    super(new BorderLayout());

    this.plotVisitList = plotVisitList;
    this.traitMap = traitMap;

    trial = plotVisitList.getTrial();// w w  w  . j  ava 2  s . co m

    fieldLayoutTableModel.setTrial(trial);

    int rowHeight = fieldLayoutTable.getRowHeight();
    fieldLayoutTable.setRowHeight(4 * rowHeight);

    fieldLayoutTable.setCellSelectionEnabled(true);

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE
    fieldLayoutTable.setAutoCreateRowSorter(false);

    Map<Integer, Plot> plotById = new HashMap<>();
    FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(),
            trial.getPlotIdentSummary(), plotVisitList.getPlots(), plotById);

    KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId,
            plotIdLayout.xsize, plotIdLayout.ysize);
    kdxFieldLayout.warning = plotIdLayout.warning;

    String displayName = null;
    for (VisitOrder2D vo : VisitOrder2D.values()) {
        if (vo.imageId == plotIdLayout.imageId) {
            displayName = vo.displayName;
            break;
        }
    }
    //      VisitOrder2D vo = plotVisitList.getVisitOrder();
    KDClientUtils.initAction(plotIdLayout.imageId, changeCollectionOrder, displayName);

    hasUserPlotId = lookForUserPlotIdPresent(plotById, plotIdLayout, kdxFieldLayout);

    this.plotCellRenderer = plotRenderer;
    plotCellRenderer.setShowUserPlotId(hasUserPlotId);

    plotCellRenderer.setPlotXYprovider(getXYprovider());

    plotCellRenderer.setPlotVisitList(plotVisitList);

    fieldLayoutTable.setDefaultRenderer(Plot.class, plotCellRenderer);
    fieldLayoutTable.setCellSelectionEnabled(true);

    fieldLayoutTableModel.setFieldLayout(kdxFieldLayout);

    if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) {
        warningMessage.setText(kdxFieldLayout.warning);
    } else {
        warningMessage.setText("");
    }

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fieldLayoutTable.getTableHeader().setReorderingAllowed(false);
    fieldLayoutTable.setCellSelectionEnabled(true);

    StringBuilder naming = new StringBuilder();
    String nameForRow = plotVisitList.getTrial().getNameForRow();
    if (!Check.isEmpty(nameForRow)) {
        naming.append(nameForRow);
    }
    String nameForCol = plotVisitList.getTrial().getNameForColumn();
    if (!Check.isEmpty(nameForCol)) {
        if (naming.length() > 0) {
            naming.append('/');
        }
        naming.append(nameForCol);
    }
    fieldTableScrollPane = new JScrollPane(fieldLayoutTable);
    if (naming.length() > 0) {
        JLabel cornerLabel = new JLabel(naming.toString());
        fieldTableScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, cornerLabel);
    }
    fieldTableScrollPane.setRowHeaderView(rowHeaderTable);

    //      fieldLayoutTable.setRowHeaderTable(rowHeaderTable);

    //      Box extra = Box.createHorizontalBox();
    //      extra.add(new JButton(changeCollectionOrder));
    //      if (extras != null && extras.length > 0) {
    //         extra.add(Box.createHorizontalStrut(8));
    //         for (Component c : extras) {
    //            extra.add(c);
    //         }
    //      }
    //      extra.add(Box.createHorizontalGlue());

    switch (visible) {
    case NOTVISIBLE:
        break;

    case VISIBLE:
    default:
        Box top = Box.createHorizontalBox();
        top.setOpaque(true);
        top.setBackground(Color.LIGHT_GRAY);
        top.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));
        JLabel label = new JLabel("Field");
        label.setForeground(Color.DARK_GRAY);
        label.setFont(label.getFont().deriveFont(Font.BOLD));
        top.add(label);
        top.add(new JButton(changeCollectionOrder));

        if (extras != null && extras.length > 0) {
            top.add(Box.createHorizontalStrut(8));
            for (Component c : extras) {
                top.add(c);
            }
        }
        add(top, BorderLayout.NORTH);
        break;
    }

    add(fieldTableScrollPane, BorderLayout.CENTER);
    add(warningMessage, BorderLayout.SOUTH);
}

From source file:com.sshtools.common.ui.SshToolsApplication.java

/**
 * Show an 'About' dialog/*from w w w .  jav  a  2s.  com*/
 *
 *
 */
public void showAbout(final Component parent) {

    JPanel p = new JPanel(new GridBagLayout());
    p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    GridBagConstraints gBC = new GridBagConstraints();
    gBC.anchor = GridBagConstraints.CENTER;
    gBC.fill = GridBagConstraints.HORIZONTAL;
    gBC.insets = new Insets(1, 1, 1, 1);

    JLabel a = new JLabel(getApplicationName());
    a.setFont(a.getFont().deriveFont(24f));
    UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER);

    MultilineLabel v = new MultilineLabel(getApplicationName() + " " + getApplicationVersion());
    v.setFont(v.getFont().deriveFont(10f));
    UIUtil.jGridBagAdd(p, v, gBC, GridBagConstraints.REMAINDER);

    MultilineLabel x = new MultilineLabel(getAboutAuthors());
    x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0));
    x.setFont(x.getFont().deriveFont(12f));
    UIUtil.jGridBagAdd(p, x, gBC, GridBagConstraints.REMAINDER);

    MultilineLabel c = new MultilineLabel(getAboutLicenseDetails());
    c.setFont(c.getFont().deriveFont(10f));
    UIUtil.jGridBagAdd(p, c, gBC, GridBagConstraints.REMAINDER);

    final JLabel h = new JLabel(getAboutURL());
    h.setForeground(Color.blue);
    h.setFont(new Font(h.getFont().getName(), Font.BOLD, 10));
    h.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    h.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            try {
                BrowserLauncher.openURL(getAboutURL());
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    });
    UIUtil.jGridBagAdd(p, h, gBC, GridBagConstraints.REMAINDER);

    JOptionPane.showMessageDialog(parent, p, "About", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon());
}

From source file:com.sshtools.common.ui.SshToolsApplication.java

public void openChangelog(Component parent) {

    JPanel p = new JPanel(new GridBagLayout());
    p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    GridBagConstraints gBC = new GridBagConstraints();
    gBC.anchor = GridBagConstraints.CENTER;
    gBC.fill = GridBagConstraints.HORIZONTAL;
    gBC.insets = new Insets(1, 1, 1, 1);

    JLabel a = new JLabel(getApplicationName());
    a.setFont(a.getFont().deriveFont(24f));
    UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER);

    String changelog = "";
    try {//www  .j  a  va  2  s  .c  om
        BufferedReader br = new BufferedReader(
                new InputStreamReader(getClass().getResourceAsStream("/changelog")));
        String line = br.readLine();
        while (line != null) {
            changelog += line + "\n";
            line = br.readLine();
        }
        br.close();
    } catch (Exception e) {
        changelog = "<Error opening changelog>\n";
    }

    javax.swing.JTextArea message = new javax.swing.JTextArea(changelog);
    message.setEditable(false);
    message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4));
    javax.swing.JLabel jl = new javax.swing.JLabel();
    message.setFont(jl.getFont());
    message.setBackground(jl.getBackground());

    //   MultilineLabel x = new MultilineLabel(changelog);
    //   x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0));
    //   x.setFont(x.getFont().deriveFont(12f));   
    javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
    scrollPane.getViewport().add(message);
    scrollPane.setSize(400, 200);
    scrollPane.setPreferredSize(new java.awt.Dimension(400, 200));
    UIUtil.jGridBagAdd(p, scrollPane, gBC, GridBagConstraints.REMAINDER);

    JOptionPane.showMessageDialog(parent, p, "Change log", JOptionPane.PLAIN_MESSAGE,
            getApplicationLargeIcon());
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

/**
 * Appends a heading with bold text that streches from the default label column to the end of the form
 *
 * @param text The text of the heading/*from w ww.j  a va 2  s. c o  m*/
 */
public void appendHeading(String text) {
    JLabel label = new JLabel(text);
    Font font = label.getFont();
    Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize());
    label.setFont(fontBold);
    append(null, null, label, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN));
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public void appendHeadingAndHelpButton(String text, String helpUrl) {
    JLabel label = new JLabel(text);
    Font font = label.getFont();
    Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize());
    label.setFont(fontBold);//from   w w w . j a  v  a  2 s.  c o  m
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(label);
    innerPanel.add(Box.createHorizontalGlue());
    innerPanel.add(UISupport.createFormButton(new ShowOnlineHelpAction(helpUrl)));
    append(null, null, innerPanel, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN));
}

From source file:edu.ku.brc.specify.plugins.TaxonLabelFormatting.java

@Override
public void initialize(Properties propertiesArg, boolean isViewModeArg) {
    super.initialize(propertiesArg, isViewModeArg);

    String plName = "TaxonLabelFormatter";
    PickListDBAdapterIFace adapter = PickListDBAdapterFactory.getInstance().create(plName, false);
    if (adapter == null || adapter.getPickList() == null) {
        throw new RuntimeException("PickList Adapter [" + plName + "] cannot be null!");
    }//  w w  w  .  j a  va 2 s .c om
    formatCBX = new ValComboBox(adapter);
    formatCBX.getComboBox().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doFormatting();
        }
    });
    formatCBX.getComboBox().addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            doFormatting();
        }
    });

    newAgentBtn = createButton(""); // Label set when new Resource Bundle is installed (below)
    searchPanel = new DBObjSearchPanel("Search", "AgentNameSearch", "AgentNameSearch",
            "edu.ku.brc.specify.datamodel.Agent", "agentId", SwingConstants.BOTTOM);
    searchPanel.getScrollPane().setMinimumSize(new Dimension(100, 200));
    searchPanel.getScrollPane().setPreferredSize(new Dimension(100, 150));
    ((FormViewObj) searchPanel.getForm()).getPanel().setBorder(null);

    try {
        UIRegistry.loadAndPushResourceBundle("specify_plugins");

        newAgentBtn.setText(getResourceString("NewAgent"));

        authorsList = new JList(new DefaultListModel());
        authorsList.setVisibleRowCount(10);
        authorsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    Object selObj = authorsList.getSelectedValue();
                    if (selObj != null) {

                    }
                    updateEnabledState();
                }
            }
        });
        JScrollPane scrollPane = new JScrollPane(authorsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        mapToBtn = createIconBtn("Map", "ADD_AUTHOR_NAME_TT", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                Object agent = searchPanel.getSelectedObject();
                ((DefaultListModel) authorsList.getModel()).addElement(agent);
                doFormatting();
            }
        });
        unmapBtn = createIconBtn("Unmap", "REMOVE_AUTHOR_NAME_TT", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                int index = authorsList.getSelectedIndex();
                if (index > -1) {
                    DefaultListModel model = (DefaultListModel) authorsList.getModel();
                    model.remove(index);
                    updateEnabledState();
                    doFormatting();
                }
            }
        });

        upBtn = createIconBtn("ReorderUp", "MOVE_AUTHOR_NAME_UP", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DefaultListModel model = (DefaultListModel) authorsList.getModel();
                int index = authorsList.getSelectedIndex();
                Object item = authorsList.getSelectedValue();
                model.remove(index);
                model.insertElementAt(item, index - 1);
                authorsList.setSelectedIndex(index - 1);
                updateEnabledState();
            }
        });
        downBtn = createIconBtn("ReorderDown", "MOVE_AUTHOR_NAME_DOWN", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DefaultListModel model = (DefaultListModel) authorsList.getModel();
                int index = authorsList.getSelectedIndex();
                Object item = authorsList.getSelectedValue();
                model.remove(index);
                model.insertElementAt(item, index + 1);
                authorsList.setSelectedIndex(index + 1);
                updateEnabledState();
            }
        });

        PanelBuilder bldr = new PanelBuilder(new FormLayout("p, 5px, p, 5px, f:p:g, 2px, p",
                "p, 4px, p, 2px, f:p:g, 4px, p, 4px, p, 2px, p, 2px, p, 2px, p"), this);
        CellConstraints cc = new CellConstraints();

        PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p, 2px, p, f:p:g"));
        upDownPanel.add(upBtn, cc.xy(1, 1));
        upDownPanel.add(downBtn, cc.xy(1, 3));

        PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, 2px, p, f:p:g"));
        middlePanel.add(mapToBtn, cc.xy(1, 2));
        middlePanel.add(unmapBtn, cc.xy(1, 4));

        PanelBuilder rwPanel = new PanelBuilder(new FormLayout("p, 2px, f:p:g", "p"));
        refWorkLabel = createLabel(getResourceString("NONE"));
        rwPanel.add(createI18NFormLabel("REFERENCEWORK"), cc.xy(1, 1));
        rwPanel.add(refWorkLabel, cc.xy(3, 1));

        int y = 1;

        bldr.add(rwPanel.getPanel(), cc.xywh(1, y, 7, 1));
        y += 2;

        bldr.add(searchPanel, cc.xywh(1, y, 1, 3));
        bldr.addSeparator(getResourceString("Authors"), cc.xy(5, y));
        y += 2;

        bldr.add(middlePanel.getPanel(), cc.xy(3, y));
        bldr.add(scrollPane, cc.xywh(5, y, 1, 3));
        bldr.add(upDownPanel.getPanel(), cc.xy(7, y));
        y += 2;

        PanelBuilder newAgentPanel = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
        newAgentPanel.add(newAgentBtn, cc.xy(2, 1));

        bldr.add(newAgentPanel.getPanel(), cc.xy(1, y));
        y += 2;

        JLabel fmtLabel = createLabel(getResourceString("LABELFORMAT"));
        bldr.add(fmtLabel, cc.xy(1, y));
        y += 2;
        bldr.add(formatCBX, cc.xywh(1, y, 7, 1));
        y += 2;

        Font plain = fmtLabel.getFont();
        specialLabel = new SpecialLabel(plain, new Font(plain.getName(), Font.ITALIC, plain.getSize()));
        specialLabel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
        bldr.add(createLabel(getResourceString("SAMPLEOUTPUT") + ":"), cc.xywh(1, y, 7, 1));
        y += 2;
        bldr.add(specialLabel, cc.xywh(1, y, 7, 1));

        searchPanel.setOKBtn(mapToBtn);
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaxonLabelFormatting.class, ex);
        log.error(ex);
        ex.printStackTrace();
    }
    UIRegistry.popResourceBundle();
}