Example usage for java.awt Font getSize

List of usage examples for java.awt Font getSize

Introduction

In this page you can find the example usage for java.awt Font getSize.

Prototype

public int getSize() 

Source Link

Document

Returns the point size of this Font , rounded to an integer.

Usage

From source file:com.petersoft.advancedswing.enhancedtextarea.EnhancedTextArea.java

private void jFontBiggerButtonActionPerformed(ActionEvent evt) {
    Font f = jTextArea.getFont();
    Font newFont = new Font(f.getFontName(), f.getStyle(), f.getSize() + 1);
    jTextArea.setFont(newFont);//from  w w  w  .  jav  a  2  s  .c o m
    lines.setFont(newFont);
}

From source file:ca.sqlpower.architect.swingui.TestPlayPenComponent.java

/**
 * Returns a new value that is not equal to oldVal. The
 * returned object will be a new instance compatible with oldVal.  
 * /*from   ww  w.j  a  v a  2 s . c  om*/
 * @param property The property that should be modified.
 * @param oldVal The existing value of the property to modify.  The returned value
 * will not equal this one at the time this method was first called.
 */
private Object getNewDifferentValue(PropertyDescriptor property, Object oldVal) throws SQLObjectException {
    Object newVal; // don't init here so compiler can warn if the
    // following code doesn't always give it a value
    if (property.getPropertyType() == String.class) {
        newVal = "new " + oldVal;
    } else if (property.getPropertyType() == Boolean.class || property.getPropertyType() == Boolean.TYPE) {
        if (oldVal == null) {
            newVal = new Boolean(false);
        } else {
            newVal = new Boolean(!((Boolean) oldVal).booleanValue());
        }
    } else if (property.getPropertyType() == Integer.class || property.getPropertyType() == Integer.TYPE) {
        if (oldVal == null) {
            newVal = new Integer(0);
        } else {
            newVal = new Integer(((Integer) oldVal).intValue() + 1);
        }
    } else if (property.getPropertyType() == Double.class || property.getPropertyType() == Double.TYPE) {
        if (oldVal == null) {
            newVal = new Double(0);
        } else {
            newVal = new Double(((Double) oldVal).doubleValue() + 1);
        }
    } else if (property.getPropertyType() == Color.class) {
        if (oldVal == null) {
            newVal = new Color(0xFAC157);
        } else {
            Color oldColor = (Color) oldVal;
            newVal = new Color((oldColor.getRGB() + 0xF00) % 0x1000000);
        }
    } else if (property.getPropertyType() == Font.class) {
        if (oldVal == null) {
            newVal = FontManager.getDefaultPhysicalFont();
        } else {
            Font oldFont = (Font) oldVal;
            newVal = new Font(oldFont.getFontName(), oldFont.getSize() + 2, oldFont.getStyle());
        }
    } else if (property.getPropertyType() == Point.class) {
        if (oldVal == null) {
            newVal = new Point();
        } else {
            Point oldPoint = (Point) oldVal;
            newVal = new Point(oldPoint.x + 10, oldPoint.y + 10);
        }
    } else if (property.getPropertyType() == Insets.class) {
        if (oldVal == null) {
            newVal = new Insets(0, 0, 0, 0);
        } else {
            Insets oldInsets = (Insets) oldVal;
            newVal = new Insets(oldInsets.top + 10, oldInsets.left + 10, oldInsets.bottom + 10,
                    oldInsets.right + 10);
        }
    } else if (property.getPropertyType() == Set.class) {
        newVal = new HashSet();
        if (property.getName().equals("hiddenColumns")) {
            ((Set) newVal).add(new SQLColumn());
        } else {
            ((Set) newVal).add("Test");
        }
    } else if (property.getPropertyType() == List.class) {
        newVal = new ArrayList();
        if (property.getName().equals("selectedColumns")) {
            ((List) newVal).add(new SQLColumn());
        } else {
            ((List) newVal).add("Test");
        }
    } else if (property.getPropertyType() == TablePane.class) {
        SQLTable t = new SQLTable();
        t.initFolders(true);
        newVal = new TablePane(t, pp.getContentPane());
    } else if (property.getPropertyType() == SQLTable.class) {
        newVal = new SQLTable();
        ((SQLTable) newVal).initFolders(true);
    } else if (property.getPropertyType() == Dimension.class) {
        newVal = new Dimension();
        if (oldVal != null) {
            ((Dimension) newVal).width = ((Dimension) oldVal).width + 1;
        }
    } else {
        throw new RuntimeException("This test case lacks a value for " + property.getName() + " (type "
                + property.getPropertyType().getName() + ") in getNewDifferentValue()");
    }

    return newVal;
}

From source file:com.limegroup.gnutella.gui.themes.setters.SubstanceThemeSetter.java

public void apply() {
    SubstanceLookAndFeel.setSkin(_skinClassName);
    ThemeMediator.applyCommonSkinUI();//  w w  w . jav  a  2  s  .co  m

    float scaledFontPolicyFactor = WINDOWS_SCALED_FONT_POLICY_FACTOR;
    if (OSUtils.isMacOSX()) {
        scaledFontPolicyFactor = MAC_SCALED_FONT_POLICY_FACTOR;
    } else if (OSUtils.isLinux()) {
        scaledFontPolicyFactor = LINUX_SCALED_FONT_POLICY_FACTOR;
    }

    if (LookUtils.IS_OS_WINDOWS) {
        fixWindowsOSFont();
    } else if (LookUtils.IS_OS_LINUX) {
        fixLinuxOSFont();
    }

    SubstanceLookAndFeel.setFontPolicy(SubstanceFontUtilities.getScaledFontPolicy(scaledFontPolicyFactor));

    //reduceFont("Label.font");
    //reduceFont("Table.font");
    //ResourceManager.setFontSizes(-1);
    //ResourceManager.setFontSizes(0);

    UIManager.put("Tree.leafIcon", UIManager.getIcon("Tree.closedIcon"));

    // remove split pane borders
    UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder());

    if (!OSUtils.isMacOSX()) {
        UIManager.put("Table.focusRowHighlightBorder", UIManager.get("Table.focusCellHighlightBorder"));
    }

    UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder(1, 1, 1, 1));

    // Add a bold text version of simple text.
    Font normal = UIManager.getFont("Table.font");
    FontUIResource bold = new FontUIResource(normal.getName(), Font.BOLD, normal.getSize());
    UIManager.put("Table.font.bold", bold);
    UIManager.put("Tree.rowHeight", 0);
}

From source file:corina.cross.AllScoresView.java

private void refreshFont() {
    // font// w  w w  . j a v  a 2s .co m
    // WAS: corina.cross.font (merged)
    Font f = App.prefs.getFontPref(Prefs.EDIT_FONT, null);
    if (f != null) {
        table.setFont(f);
        table.setRowHeight(f.getSize() + 3);
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java

protected void saveFontPreferences(Element element) {
    if (table.getFont() != null) {
        Font font = table.getFont();
        Map<TextAttribute, ?> attributes = font.getAttributes();
        // save content font
        element.addAttribute("fontFamily", font.getFamily());
        element.addAttribute("fontSize", Integer.toString(font.getSize()));
        element.addAttribute("fontStyle", Integer.toString(font.getStyle()));
        element.addAttribute("fontUnderline",
                Boolean.toString(attributes.get(TextAttribute.UNDERLINE) == TextAttribute.UNDERLINE_ON));
    }/*  w  ww .  j  a v a 2s.c om*/
}

From source file:net.chaosserver.timelord.swingui.TaskDayPanel.java

/**
 * Builds the panel. This uses a GridBag to try and make formatting
 * grid-like between the unconnected rows.
 *///from w w w  .j ava  2s  . c o  m
protected void buildPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    Insets defaultInsets = gridBagConstraints.insets;

    setLayout(gridBagLayout);

    taskName = new JLabel();

    if (timelordTask.isHidden()) {
        Font taskFont = taskName.getFont();
        Font italicFont = new Font(taskFont.getName(), Font.ITALIC, taskFont.getSize());
        taskName.setFont(italicFont);
    }

    updateTaskNameLabel();
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagLayout.addLayoutComponent(taskName, gridBagConstraints);
    add(taskName);

    minusButton = new JButton("-" + DateUtil.getSmallestTimeInMinutes() + "m");

    minusButton.setToolTipText("Remove 15 minutes (0.25 hours) " + "of time from this task.");
    minusButton.setActionCommand(ACTION_MINUS_15);
    minusButton.addActionListener(this);
    gridBagConstraints.anchor = GridBagConstraints.CENTER;
    gridBagConstraints.insets = defaultInsets;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagLayout.addLayoutComponent(minusButton, gridBagConstraints);
    add(minusButton);

    addButton = new JButton("+" + DateUtil.getSmallestTimeInMinutes() + "m");

    addButton.setToolTipText("Add 15 minutes (0.25 hours) of " + "time from this task.");
    addButton.setActionCommand(ACTION_ADD_15);
    addButton.addActionListener(this);
    gridBagConstraints.anchor = GridBagConstraints.CENTER;
    gridBagConstraints.insets = defaultInsets;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagLayout.addLayoutComponent(addButton, gridBagConstraints);
    add(addButton);

    timeLabel = new JLabel();

    if (todayTaskDay != null) {
        timeLabel.setText(DateUtil.formatHours(null, todayTaskDay.getHours()));
    } else {
        timeLabel.setText(DateUtil.formatHours(null, 0));
    }

    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
    gridBagLayout.addLayoutComponent(timeLabel, gridBagConstraints);
    add(timeLabel);

    enabledButtons();
}

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

/**
 * Sets the text explaining the component when the component is a list
 * or a map.//from   w  w w .ja  v  a 2 s  . c  o m
 * 
 * @param text The value to set.
 */
void setInfo(String text) {
    if (StringUtils.isBlank(text))
        return;
    info = new JLabel();
    Font f = info.getFont();
    info.setFont(f.deriveFont(Font.ITALIC, f.getSize() - 2));
}

From source file:org.tinymediamanager.ui.movies.settings.MovieSubtitleSettingsPanel.java

private void initComponents() {
    // data init// ww w.ja  v  a 2s.  com
    List<String> enabledSubtitleProviders = settings.getMovieSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : MovieList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

    tableScraper = new JTable();
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    add(lblScraperLanguage, "2, 4, right, default");

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addMovieSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeMovieSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default movie scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSubtitleSettingsPanel.java

private void initComponents() {
    // data init/*from w  ww  . j a v  a 2  s. c o m*/
    List<String> enabledSubtitleProviders = settings.getTvShowSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : TvShowList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

    tableScraper = new JTable();
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    add(lblScraperLanguage, "2, 4, right, default");

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addTvShowSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeTvShowSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default tv show subtitle scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:com.tulskiy.musique.system.configuration.Configuration.java

public void setFont(String key, Font value) {
    if (value == null)
        remove(key);/*ww  w . ja v  a  2s .co m*/
    else {
        String s = new Formatter().format("%s, %d, %d", value.getName(), value.getStyle(), value.getSize())
                .toString();
        put(key, s);
    }
}