Java Swing Font Change ChangeFont(JComponent comp, int wheel_rotation)

Here you can find the source of ChangeFont(JComponent comp, int wheel_rotation)

Description

Change Font

License

Open Source License

Declaration

public static void ChangeFont(JComponent comp, int wheel_rotation) 

Method Source Code

//package com.java2s;
/*Copyright 2008 by Vladimir Polony, Stupy 24, Banska Bystrica, Slovakia
    //from  w  w w . j  a va2s . co  m
This file is part of OpenRep FREE homeopathic software.
    
OpenRep FREE 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.
    
OpenRep FREE 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 OpenRep FREE.  If not, see <http://www.gnu.org/licenses/>.*/

import java.awt.Font;

import javax.swing.JComponent;

public class Main {
    public static void ChangeFont(JComponent comp, int wheel_rotation) {
        int size_inc = 0;
        if (wheel_rotation > 0)
            size_inc++;
        else if (wheel_rotation < 0)
            size_inc--;
        if (size_inc != 0) {
            Font f = new Font(comp.getFont().getName(), comp.getFont().getStyle(),
                    comp.getFont().getSize() + size_inc);
            comp.setFont(f);
            comp.repaint();
        }
    }
}

Related

  1. changeDefaultFontSize(int fontSize)
  2. changeFont(JComponent comp, double scaleFactor, int style)
  3. changeFontSize(final int size)
  4. changeFontSize(Font font, float factor)
  5. changeFontStyle(Font font, int style)
  6. changeFontToItalic(final JComponent component)