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:com.lottery.gui.MainLotteryForm.java

private void btnAddNumberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddNumberActionPerformed
    try {//from w  w  w.j  a  v a2 s .  co m
        Integer number = Integer.parseInt(inputNumberTf.getText());
        if (inputNumbers.contains(number)) {
            JOptionPane.showMessageDialog(this, "Number has already existed!");
            return;
        }

        if (number > LotteryUtils.MAX_BALL_VALUE || number < LotteryUtils.MIN_BALL_VALUE) {
            JOptionPane.showMessageDialog(this, "Invalid range (" + LotteryUtils.MIN_BALL_VALUE + " - "
                    + LotteryUtils.MAX_BALL_VALUE + ")!");
            return;
        }

        JLabel numberLbl = new JLabel(number + "");
        numberLbl.setOpaque(true);
        //numberLbl.setMinimumSize(new Dimension(100, 100));
        //        numberLbl.setPreferredSize(new Dimension(400, 100));
        //        numberLbl.setBackground(Color.white);
        numberLbl.setForeground(Color.red);
        setFont(numberLbl.getFont().deriveFont(150f));
        numberLbl.setFont(new Font("Serif", Font.PLAIN, 30));

        int numberOfInput = inputNumbers.size();
        int row = numberOfInput / NO_NUMBER_PER_ROW;
        int col = numberOfInput % NO_NUMBER_PER_ROW;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = col;
        c.gridy = row;
        c.weightx = 0.5;
        ballNumbersPanel.add(numberLbl, c);
        lbNumbers.add(numberLbl);
        inputNumbers.add(number);

        ballNumbersPanel.revalidate();
        ballNumbersPanel.repaint();

        inputNumberTf.setText("");
        inputNumberTf.requestFocusInWindow();

        //            // check if has winner
        //            Date today = LotteryUtils.getNextDate(new Date());
        //            if (dbTicketTables.isEmpty()) {
        //                dbTicketTables = ticketTableService.getByDate(today);
        //            }

        totalDrawedNumbers++;
        checkCanAddNumber();

        if (inputNumbers.size() < LotteryUtils.MAX_BALLS_PER_LINE) {
            return;
        }

        winTicketTables.addAll(LotteryUtils.getWinnerByLine(dbTicketTables, inputNumbers));

        if (winTicketTables.size() > 0) {
            // update table list view
            refreshWinnerTable();
            //                JOptionPane.showMessageDialog(this, "Number of winner: " + winTicketTables.size());
        }

        // check if has full table, then stop game
        if (totalDrawedNumbers >= (LotteryUtils.MAX_BALLS_PER_LINE * LotteryUtils.NO_LINES_PER_TABLE)) {
            Iterator<TicketTable> iter = winTicketTables.iterator();
            while (iter.hasNext()) {
                TicketTable tmp = iter.next();
                if (tmp.getWinType() == TicketTable.FULL_TABLE) {
                    JOptionPane.showMessageDialog(this, "Got winner with full table!");

                    // save draw results, update ticket_table winner
                    DrawResult drawResult = new DrawResult();
                    drawResult.setDrawDate(LotteryUtils.getDate(ftfDrawDate.getText().trim()));
                    drawResult.setDrawBalls(StringUtils.join(inputNumbers, LotteryUtils.BALLS_SEPARATOR));
                    drawResult.setRound(Byte.parseByte((String) cbbRound.getSelectedItem()));

                    drawResultService.updateWinner(drawResult, winTicketTables);
                    restartGame();

                    return;
                }
            }
        }

    } catch (NumberFormatException ex) {
        LOGGER.error("Invalid number!: ", ex);
        JOptionPane.showMessageDialog(this, "Invalid number!");
    } catch (ParseException ex) {
        LOGGER.error("Cant parse date", ex);
        JOptionPane.showMessageDialog(this, "Cant save result!");
    }

}

From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java

/**
 * /*from   w w w .  ja  va2  s.  c  om*/
 */
protected void showForm() {
    if (selectedForm != null) {
        if (formFrame != null) {
            formFrame.setVisible(false);
            formFrame.dispose();
        }

        formFrame = new JFrame();

        FormPanelInfo formPanelInfo = createPanel(selectedForm);
        JPanel panel = formPanelInfo.getPanel();

        JLabel label = new JLabel(formPanelInfo.getTitle(), SwingConstants.CENTER);
        Font font = label.getFont();

        label.setFont(font.deriveFont(14.0f).deriveFont(Font.BOLD));

        JPanel container = new JPanel(new BorderLayout());

        container.add(panel, BorderLayout.CENTER);
        container.add(label, BorderLayout.SOUTH);

        formFrame.setContentPane(container);

        panel.addMouseMotionListener(new MouseAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                //System.out.println(e.getPoint());
            }
        });

        formFrame.setVisible(true);
        formFrame.setSize(new Dimension(formPanelInfo.getMaxWidth() + 10, formPanelInfo.getMaxHeight() + 25));
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java

/**
 * Creates one panel for each kind of form that may be used and stores them for later
 *///from www. j av a  2  s . c om
private void createInitialInfoSubPanels() {
    //boolean editing = hasPermissionToModify;

    infoSubPanels = new Hashtable<String, AdminInfoSubPanelWrapper>();

    JPanel blankPanel = new JPanel();
    createBlankInfoSubPanel(Institution.class, blankPanel);
    createBlankInfoSubPanel(Discipline.class, blankPanel);
    createBlankInfoSubPanel(Collection.class, blankPanel);

    JPanel allPermissions = new JPanel(new BorderLayout());
    JLabel lbl = UIHelper.createI18NLabel("SEC_ALL_PERMISSIONS", SwingConstants.CENTER);
    lbl.setFont(lbl.getFont().deriveFont(18.0f));
    allPermissions.add(lbl, BorderLayout.CENTER);

    createBlankInfoSubPanel(AdminPrincipal.class, allPermissions);

    createUserPanel();
    createGroupPanel();
}

From source file:SuitaDetails.java

private void initComponents(ArrayList<String[]> descriptions) {
    global = new JPanel();
    global.setBackground(Color.WHITE);
    initGlobal();/*from  ww  w. j a  v a  2  s .  c o  m*/
    initTCOptions();
    initSummary();
    definitions.clear();
    border = BorderFactory.createTitledBorder("Global options");
    setBorder(border);
    scroll = new JScrollPane();
    //         setMinimumSize(new Dimension(10,10));
    //         setMaximumSize(new Dimension(1000,1000));
    //         setPreferredSize(new Dimension(100,100));
    defsContainer = new JPanel();
    setLayout(new BorderLayout());
    defsContainer.setBackground(Color.WHITE);
    defsContainer.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
    defsContainer.setLayout(new BoxLayout(defsContainer, BoxLayout.Y_AXIS));
    defsContainer.add(suiteoptions);
    scroll.setViewportView(global);
    add(scroll, BorderLayout.CENTER);
    JLabel l = new JLabel("test");
    FontMetrics metrics = l.getFontMetrics(l.getFont());
    int width = 0;
    for (int i = 0; i < descriptions.size(); i++) {
        if (width < metrics.stringWidth(descriptions.get(i)[RunnerRepository.LABEL])) {
            width = metrics.stringWidth(descriptions.get(i)[RunnerRepository.LABEL]);
        }
    }
    for (int i = 0; i < descriptions.size(); i++) {
        String button = descriptions.get(i)[RunnerRepository.SELECTED];
        DefPanel define = new DefPanel(descriptions.get(i)[RunnerRepository.LABEL], button,
                descriptions.get(i)[RunnerRepository.ID], width, i, this);
        definitions.add(define);
        defsContainer.add(define);
    }
}

From source file:Main.Interface_Main.java

private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed

    // for copying style
    JLabel label = new JLabel();
    Font font = label.getFont();

    // create some css from the label's font
    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
    style.append("font-size:" + font.getSize() + "pt;");

    // html content
    JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
            + "This application was designed by <A HREF=http://www.friedcircuits.us>FriedCircuits</A> for the USB Tester." //
            + "<br><br><center>App Version: " + appVersion + "<br>FW Version: " + FW_VERSION
            + "</center><br><br>*Connect once to get FW version.</body></html>");

    // handle link events
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override//from   www  . ja  v a2 s .co  m
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

                URI uri;
                try {
                    uri = new java.net.URI("www.friedcircuits.us");
                    if (desktop.isSupported(Desktop.Action.BROWSE)) {
                        try {
                            desktop.browse(uri);
                        } catch (IOException ex) {
                            Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                } catch (URISyntaxException ex) {
                    Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex);
                }

            } // roll your own link launcher or use Desktop if J6+
        }
    });
    Color bgColor = label.getBackground();
    UIDefaults defaults = new UIDefaults();
    defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
    ep.putClientProperty("Nimbus.Overrides", defaults);
    ep.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    ep.setEditable(false);
    ep.setBackground(bgColor);

    // show
    ImageIcon myCustomIcon = new ImageIcon(getClass().getResource("/faviconbot2edit.png"));
    JOptionPane.showMessageDialog(plCurrent, ep, "About", JOptionPane.INFORMATION_MESSAGE, myCustomIcon);
}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Initializes the GUI./*from  www  .ja  v  a 2s .  c  o  m*/
 *
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initGUI() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    // add attribute name
    panelAttName = new JPanel();
    panelAttName.setLayout(new BoxLayout(panelAttName, BoxLayout.PAGE_AXIS));
    panelAttName.setOpaque(false);
    // this border is to visualize that the name column can be enlarged/shrinked
    panelAttName.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY));

    labelAttHeader = new JLabel(LABEL_DOTS);
    labelAttHeader.setFont(labelAttHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelAttHeader.setForeground(Color.GRAY);
    panelAttName.add(labelAttHeader);

    labelAttName = new JLabel(LABEL_DOTS);
    labelAttName.setFont(labelAttName.getFont().deriveFont(Font.BOLD, FONT_SIZE_LABEL_VALUE));
    labelAttName.setMinimumSize(DIMENSION_LABEL_ATTRIBUTE);
    labelAttName.setPreferredSize(DIMENSION_LABEL_ATTRIBUTE);
    panelAttName.add(labelAttName);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(3, 20, 3, 10);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.0;
    gbc.weighty = 1.0;
    gbc.gridheight = 2;
    add(panelAttName, gbc);

    // create value type name and bring it to a nice to read format (aka uppercase first letter
    // and replace '_' with ' '
    gbc.gridx += 1;
    gbc.insets = new Insets(5, 15, 5, 10);
    labelAttType = new JLabel(LABEL_DOTS);
    labelAttType.setMinimumSize(DIMENSION_LABEL_TYPE);
    labelAttType.setPreferredSize(DIMENSION_LABEL_TYPE);
    add(labelAttType, gbc);

    // missings panel
    JPanel panelStatsMissing = new JPanel();
    panelStatsMissing.setLayout(new BoxLayout(panelStatsMissing, BoxLayout.PAGE_AXIS));
    panelStatsMissing.setOpaque(false);

    labelStatsMissing = new JLabel(LABEL_DOTS);
    labelStatsMissing.setMinimumSize(DIMENSION_LABEL_MISSINGS);
    labelStatsMissing.setPreferredSize(DIMENSION_LABEL_MISSINGS);
    panelStatsMissing.add(labelStatsMissing);

    gbc.gridx += 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(panelStatsMissing, gbc);

    // chart panel(s) (only visible when enlarged)
    JPanel chartPanel = new JPanel(new BorderLayout());
    chartPanel.setBackground(COLOR_TRANSPARENT);
    chartPanel.setOpaque(false);
    listOfChartPanels.add(chartPanel);
    updateVisibilityOfChartPanels();

    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.insets = new Insets(0, 10, 0, 10);
    for (JPanel panel : listOfChartPanels) {
        gbc.gridx += 1;
        add(panel, gbc);
    }

    // (hidden) construction panel
    String constructionLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.construction.label");
    panelStatsConstruction = new JPanel();
    panelStatsConstruction.setLayout(new BoxLayout(panelStatsConstruction, BoxLayout.PAGE_AXIS));
    panelStatsConstruction.setOpaque(false);
    panelStatsConstruction.setVisible(false);

    JLabel labelConstructionHeader = new JLabel(constructionLabel);
    labelConstructionHeader.setFont(labelConstructionHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelConstructionHeader.setForeground(Color.GRAY);
    panelStatsConstruction.add(labelConstructionHeader);

    labelStatsConstruction = new JLabel(LABEL_DOTS);
    labelStatsConstruction.setFont(labelStatsConstruction.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    labelStatsConstruction.setMinimumSize(DIMENSION_LABEL_CONSTRUCTION);
    labelStatsConstruction.setPreferredSize(DIMENSION_LABEL_CONSTRUCTION);
    panelStatsConstruction.add(labelStatsConstruction);

    gbc.gridx += 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(panelStatsConstruction, gbc);

    // statistics panel, contains different statistics panels for numerical/nominal/date_time on
    // a card layout
    // needed to switch between for model swapping
    cardStatsPanel = new JPanel();
    cardStatsPanel.setOpaque(false);
    cardLayout = new CardLayout();
    cardStatsPanel.setLayout(cardLayout);

    // numerical version
    JPanel statsNumPanel = new JPanel();
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints gbcStatPanel = new GridBagConstraints();
    statsNumPanel.setLayout(layout);
    statsNumPanel.setOpaque(false);

    String avgLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.avg.label");
    String devianceLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.variance.label");
    String minLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.min.label");
    String maxLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.max.label");

    // min value panel
    JPanel panelStatsMin = new JPanel();
    panelStatsMin.setLayout(new BoxLayout(panelStatsMin, BoxLayout.PAGE_AXIS));
    panelStatsMin.setOpaque(false);

    JLabel labelMinHeader = new JLabel(minLabel);
    labelMinHeader.setFont(labelMinHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMinHeader.setForeground(Color.GRAY);
    panelStatsMin.add(labelMinHeader);

    labelStatsMin = new JLabel(LABEL_DOTS);
    labelStatsMin.setFont(labelStatsMin.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMin.add(labelStatsMin);

    // max value panel
    JPanel panelStatsMax = new JPanel();
    panelStatsMax.setLayout(new BoxLayout(panelStatsMax, BoxLayout.PAGE_AXIS));
    panelStatsMax.setOpaque(false);

    JLabel labelMaxHeader = new JLabel(maxLabel);
    labelMaxHeader.setFont(labelMaxHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMaxHeader.setForeground(Color.GRAY);
    panelStatsMax.add(labelMaxHeader);

    labelStatsMax = new JLabel(LABEL_DOTS);
    labelStatsMax.setFont(labelStatsMax.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMax.add(labelStatsMax);

    // average value panel
    JPanel panelStatsAvg = new JPanel();
    panelStatsAvg.setLayout(new BoxLayout(panelStatsAvg, BoxLayout.PAGE_AXIS));
    panelStatsAvg.setOpaque(false);

    JLabel labelAvgHeader = new JLabel(avgLabel);
    labelAvgHeader.setFont(labelAvgHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelAvgHeader.setForeground(Color.GRAY);
    panelStatsAvg.add(labelAvgHeader);

    labelStatsAvg = new JLabel(LABEL_DOTS);
    labelStatsAvg.setFont(labelStatsAvg.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsAvg.add(labelStatsAvg);

    // deviance value panel
    JPanel panelStatsDeviance = new JPanel();
    panelStatsDeviance.setLayout(new BoxLayout(panelStatsDeviance, BoxLayout.PAGE_AXIS));
    panelStatsDeviance.setOpaque(false);

    JLabel labelDevianceHeader = new JLabel(devianceLabel);
    labelDevianceHeader.setFont(labelDevianceHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelDevianceHeader.setForeground(Color.GRAY);
    panelStatsDeviance.add(labelDevianceHeader);

    labelStatsDeviation = new JLabel(LABEL_DOTS);
    labelStatsDeviation.setFont(labelStatsDeviation.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsDeviance.add(labelStatsDeviation);

    // add sub panels to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 4);
    panelStatsMin.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsMin, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsMax.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsMax, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsAvg.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsAvg, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsDeviance.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsDeviance, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsNumPanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsNumPanel, CARD_NUMERICAL);

    // nominal version
    JPanel statsNomPanel = new JPanel();
    statsNomPanel.setLayout(layout);
    statsNomPanel.setOpaque(false);
    String leastLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.least.label");
    String mostLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.most.label");
    String valuesLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.values.label");

    // least panel
    JPanel panelStatsLeast = new JPanel();
    panelStatsLeast.setLayout(new BoxLayout(panelStatsLeast, BoxLayout.PAGE_AXIS));
    panelStatsLeast.setOpaque(false);

    JLabel labelLeastHeader = new JLabel(leastLabel);
    labelLeastHeader.setFont(labelLeastHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelLeastHeader.setForeground(Color.GRAY);
    labelLeastHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsLeast.add(labelLeastHeader);

    labelStatsLeast = new JLabel(LABEL_DOTS);
    labelStatsLeast.setFont(labelStatsLeast.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsLeast.add(labelStatsLeast);

    // most panel
    JPanel panelStatsMost = new JPanel();
    panelStatsMost.setLayout(new BoxLayout(panelStatsMost, BoxLayout.PAGE_AXIS));
    panelStatsMost.setOpaque(false);

    JLabel labelMostHeader = new JLabel(mostLabel);
    labelMostHeader.setFont(labelMostHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMostHeader.setForeground(Color.GRAY);
    labelMostHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsMost.add(labelMostHeader);

    labelStatsMost = new JLabel(LABEL_DOTS);
    labelStatsMost.setFont(labelStatsMost.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMost.add(labelStatsMost);

    // values panel
    JPanel panelStatsValues = new JPanel();
    panelStatsValues.setLayout(new BoxLayout(panelStatsValues, BoxLayout.PAGE_AXIS));
    panelStatsValues.setOpaque(false);

    JLabel labelValuesHeader = new JLabel(valuesLabel);
    labelValuesHeader.setFont(labelValuesHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelValuesHeader.setForeground(Color.GRAY);
    labelValuesHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsValues.add(labelValuesHeader);

    labelStatsValues = new JLabel(LABEL_DOTS);
    labelStatsValues.setFont(labelStatsValues.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsValues.add(labelStatsValues);

    detailsButton = new JButton(new ShowNomValueAction(this));
    detailsButton.setVisible(false);
    detailsButton.setOpaque(false);
    detailsButton.setContentAreaFilled(false);
    detailsButton.setBorderPainted(false);
    detailsButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
    detailsButton.setHorizontalAlignment(SwingConstants.LEFT);
    detailsButton.setHorizontalTextPosition(SwingConstants.LEFT);
    detailsButton.setIcon(null);
    Font font = detailsButton.getFont();
    Map attributes = font.getAttributes();
    attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    detailsButton.setFont(font.deriveFont(attributes));
    panelStatsValues.add(detailsButton);

    // add sub panel to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 6);
    panelStatsLeast.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE);
    statsNomPanel.add(panelStatsLeast, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsMost.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE);
    statsNomPanel.add(panelStatsMost, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    statsNomPanel.add(panelStatsValues, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsNomPanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsNomPanel, CARD_NOMINAL);

    // date_time version
    JPanel statsDateTimePanel = new JPanel();
    statsDateTimePanel.setLayout(layout);
    statsDateTimePanel.setOpaque(false);

    String durationLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.duration.label");
    String fromLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.from.label");
    String untilLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.until.label");

    // min value panel
    JPanel panelStatsFrom = new JPanel();
    panelStatsFrom.setLayout(new BoxLayout(panelStatsFrom, BoxLayout.PAGE_AXIS));
    panelStatsFrom.setOpaque(false);

    JLabel labelFromHeader = new JLabel(fromLabel);
    labelFromHeader.setFont(labelFromHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelFromHeader.setForeground(Color.GRAY);
    panelStatsFrom.add(labelFromHeader);

    labelStatsFrom = new JLabel(LABEL_DOTS);
    labelStatsFrom.setFont(labelStatsFrom.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsFrom.add(labelStatsFrom);

    // until value panel
    JPanel panelStatsUntil = new JPanel();
    panelStatsUntil.setLayout(new BoxLayout(panelStatsUntil, BoxLayout.PAGE_AXIS));
    panelStatsUntil.setOpaque(false);

    JLabel labelUntilHeader = new JLabel(untilLabel);
    labelUntilHeader.setFont(labelUntilHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelUntilHeader.setForeground(Color.GRAY);
    panelStatsUntil.add(labelUntilHeader);

    labelStatsUntil = new JLabel(LABEL_DOTS);
    labelStatsUntil.setFont(labelStatsUntil.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsUntil.add(labelStatsUntil);

    // duration value panel
    JPanel panelStatsDuration = new JPanel();
    panelStatsDuration.setLayout(new BoxLayout(panelStatsDuration, BoxLayout.PAGE_AXIS));
    panelStatsDuration.setOpaque(false);

    JLabel labelDurationHeader = new JLabel(durationLabel);
    labelDurationHeader.setFont(labelDurationHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelDurationHeader.setForeground(Color.GRAY);
    panelStatsDuration.add(labelDurationHeader);

    labelStatsDuration = new JLabel(LABEL_DOTS);
    labelStatsDuration.setFont(labelStatsDuration.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsDuration.add(labelStatsDuration);

    // add sub panels to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 6);
    panelStatsFrom.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsFrom, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsUntil.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsUntil, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsDuration.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsDuration, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsDateTimePanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsDateTimePanel, CARD_DATE_TIME);

    // add stats panel to main gui
    gbc.gridx += 1;
    gbc.insets = new Insets(5, 10, 5, 10);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.WEST;
    add(cardStatsPanel, gbc);

    // needed so we can draw our own background
    setOpaque(false);

    // handle mouse events for hover effect and enlarging/shrinking
    addMouseListener(enlargeAndHoverAndPopupMouseAdapter);

    // change cursor to indicate this component can be clicked
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

private Component makeComponentForTab(KdxApp kdxApp, Component uiComponent) {
    Component appComponent = uiComponent;
    DevelopmentState devState = kdxApp.getDevelopmentState();
    if (devState.getShouldShowHeading()) {
        JLabel heading = new JLabel(devState.getHeadingText(), JLabel.CENTER);
        heading.setOpaque(true);/*from w w w . ja  v a2s  .c  om*/
        heading.setForeground(devState.getHeadingFontColor());
        heading.setBackground(Color.LIGHT_GRAY);
        heading.setFont(heading.getFont().deriveFont(Font.BOLD));

        JPanel p = new JPanel(new BorderLayout());
        p.add(heading, BorderLayout.NORTH);
        //Color.DARK_GRAY, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY
        //            p.add(GuiUtil.createLabelSeparator(devState.getHeadingText(), fontColor, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY),
        //                    BorderLayout.NORTH);
        p.add(uiComponent, BorderLayout.CENTER);
        appComponent = p;
    }
    return appComponent;
}

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

@Override
public void setParent(final FormViewObj parent) {
    this.parent = parent;

    JLabel lbl = parent.getLabelFor(this);
    if (lbl != null && StringUtils.isNotEmpty(dateFieldName)) {
        DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByClassName(parent.getView().getClassName());
        if (tblInfo != null) {
            final DBFieldInfo fi = tblInfo.getFieldByName(dateFieldName);
            if (fi != null) {
                title = fi.getTitle();/*from w  w w  .  j  a  va  2 s  .  c  o  m*/
                isRequired = fi.isRequired();
                if (uivs[0] instanceof ValFormattedTextFieldSingle) {
                    ((ValFormattedTextFieldSingle) uivs[0]).setRequired(isRequired);
                } else {
                    for (UIValidatable uiv : uivs) {
                        ((ValFormattedTextField) uiv).setRequired(isRequired);
                    }
                }

                if (StringUtils.isNotEmpty(fi.getTitle())) {
                    lbl.setText(fi.getTitle() + ":");
                    if (isRequired) {
                        lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
                    }
                }

                if (lbl != null) {
                    lbl.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent e) {
                            super.mouseClicked(e);
                            if (e.getClickCount() == 2) {
                                JOptionPane.showMessageDialog(UIRegistry.getMostRecentWindow(),
                                        "<html>" + fi.getDescription(),
                                        UIRegistry.getResourceString("FormViewObj.UNOTES"),
                                        JOptionPane.INFORMATION_MESSAGE);
                            }
                        }
                    });
                }
            } else {
                log.error("PartialDateUI - Couldn't find date field [" + dateFieldName + "] in data obj View: "
                        + parent.getView().getName());
            }
        }
    }
}

From source file:beproject.MainGUI.java

void createTagCloud() throws SQLException {
    TreeMap tmp = getFrequentWords();
    Cloud cld = new Cloud();
    JPanel tmpPanel = new JPanel();
    FlowLayout t1 = new FlowLayout();
    tmpPanel.setPreferredSize(new Dimension(512, 512));
    tmpPanel.setLayout(t1);//www. ja  va  2s  .c  om
    tmpPanel.setBounds(0, 0, 512, 512);
    //FlowLayout lm=(FlowLayout) tmpPanel.getLayout();
    for (int i = 0; i < 40 && !tmp.isEmpty(); i++) {
        Map.Entry mp = tmp.pollFirstEntry();
        Tag t = new Tag((String) mp.getKey(), (int) (mp.getValue()));
        cld.addTag(t);
    }
    Random rand = new Random();
    for (Tag tag : cld.tags()) {
        final JLabel label = new JLabel(tag.getName());
        label.setOpaque(false);
        label.setFont(label.getFont().deriveFont(rand.nextFloat() * 39));
        label.setForeground(new Color(rand.nextInt()));
        tmpPanel.add(label);
    }
    if (tagCloudPanel == null) {
        tagCloudPanel = new JScrollPane(tmpPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    } else {
        jPanel3.remove(tagCloudPanel);
        jPanel3.validate();
        tagCloudPanel = new JScrollPane(tmpPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    }
    //tagCloudPanel.setLayout(new ScrollPaneLayout());
    //tagCloudPanel.setAutoscrolls(true);
    tmpPanel.validate();
    tagCloudPanel.validate();
    jPanel3.add(tagCloudPanel, BorderLayout.CENTER);
    jPanel3.validate();

}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

/**
 * Reset all day labels back to plain font.
 *//*from w w w .java 2  s  . c  om*/
private void resetAllDayLabels() {
    JLabel[] labels = { jLabel9, jLabel10, jLabel11, jLabel12, jLabel13, jLabel14, jLabel5, jLabel6 };
    for (JLabel label : labels) {
        final Font oldFont = label.getFont();
        // Reset BOLD attribute.
        final Font font = oldFont.deriveFont(oldFont.getStyle() & ~Font.BOLD);
        label.setFont(font);
    }
}