Java Swing Font Change changeFontSize(Font font, float factor)

Here you can find the source of changeFontSize(Font font, float factor)

Description

change Font Size

License

Open Source License

Declaration

public static Font changeFontSize(Font font, float factor) 

Method Source Code

//package com.java2s;

import java.awt.Font;

import javax.swing.JComponent;

public class Main {
    public static Font changeFontSize(Font font, float factor) {
        int size = (int) Math.round(factor * font.getSize());
        if (size < 6)
            size = Math.max(6, font.getSize());
        return new Font(font.getName(), font.getStyle(), size);
    }// w ww  . ja  va  2 s  .co m

    public static void changeFontSize(JComponent component, float factor) {
        component.setFont(changeFontSize(component.getFont(), factor));
    }
}

Related

  1. changeDefaultFontSize(int fontSize)
  2. changeFont(JComponent comp, double scaleFactor, int style)
  3. ChangeFont(JComponent comp, int wheel_rotation)
  4. changeFontSize(final int size)
  5. changeFontStyle(Font font, int style)
  6. changeFontToItalic(final JComponent component)
  7. installFont(Component c, Font font)
  8. installFont(Component c, Font font)