Java Folder Size Get setFontSize(final C component, final int fontSize)

Here you can find the source of setFontSize(final C component, final int fontSize)

Description

Sets font size of the specified component.

License

Open Source License

Parameter

Parameter Description
component component to modify
fontSize new font size
C component type

Return

modified component

Declaration

public static <C extends Component> C setFontSize(final C component, final int fontSize) 

Method Source Code

//package com.java2s;
/*/*w w w  . j  av  a  2  s  . co m*/
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.*;

public class Main {
    /**
     * Sets font size of the specified component.
     *
     * @param component component to modify
     * @param fontSize  new font size
     * @param <C>       component type
     * @return modified component
     */
    public static <C extends Component> C setFontSize(final C component, final int fontSize) {
        if (component != null && component.getFont() != null) {
            component.setFont(component.getFont().deriveFont((float) fontSize));
        }
        return component;
    }
}

Related

  1. fontSize(Font f)
  2. fontSize(Font f)
  3. setFileChooserFont(Component[] comp, int newFontSize)
  4. setFontOfPixelHeight(Graphics2D g, int style, double targetSize)
  5. setFontSize(Component c, float size)
  6. setFontSize(int size, Graphics g)
  7. setMonospacedFont(int size, Component... components)