Example usage for java.awt Component setFont

List of usage examples for java.awt Component setFont

Introduction

In this page you can find the example usage for java.awt Component setFont.

Prototype

public void setFont(Font f) 

Source Link

Document

Sets the font of this component.

Usage

From source file:Main.java

/**
 * Set {@link #deriveHeader2(Component)} font on component.
 * @param context/* w w w  .  j  a  va  2s.  co  m*/
 */
public static void setHeader2(Component context) {
    context.setFont(deriveHeader2(context));
}

From source file:Main.java

/**
 * Set {@link #deriveHeader1(Component)} font on component.
 * @param context//from  ww  w  .  ja va2s .  c  o  m
 */
public static void setHeader1(Component context) {
    context.setFont(deriveHeader1(context));
}

From source file:Main.java

/**
 * Sets the bold font.// w ww. j  a  v  a 2s  . c o  m
 *
 * @param comp
 *            the new bold font
 */
public static void setBoldFont(final Component comp) {
    comp.setFont(new Font("Tahoma", Font.BOLD, 10));
}

From source file:Main.java

public static void setComponentsFont(Container container, Font font) {
    Component[] components = container.getComponents();
    container.setFont(font);/*from   w  w  w  . j  av  a  2 s  .  com*/

    for (Component component : components) {
        component.setFont(font);
        if (component instanceof JMenu) {
            setComponentsFont((Container) component, font);
        }
    }
}

From source file:Main.java

/** Set the font property of the given components.  Intended to reduce clutter in GUI code. */
public static void setFont(Font f, Component... components) {
    for (Component c : components) {
        c.setFont(f);
    }/*from   www .  jav a  2 s. com*/
}

From source file:Main.java

/**
 * Sets the font for an entire component hierarchy to the specified font.
 * //from   w  w w .j a v  a  2 s .  c  om
 * @param c
 *            the starting component
 * @param font
 *            the font to set
 */
public static void setComponentTreeFont(Component c, Font font) {
    c.setFont(font);

    Component[] children = getChildren(c);

    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            setComponentTreeFont(children[i], font);
        }
    }
}

From source file:Main.java

public static void setFont(Container container, Font font) {
    container.setFont(font);//w  w  w .  ja v  a  2  s.co m
    trySetBorderFont(font, container);
    Component[] components = container.getComponents();
    for (Component component : components) {
        component.setFont(font);
        if (component instanceof Container) {
            setFont((Container) component, font);
        }
        trySetBorderFont(font, component);
        if (component instanceof JTable) {
            JTable table = (JTable) component;
            table.getTableHeader().setFont(font);
        }
    }

    if (container instanceof JMenu) {
        JMenu jMenu = (JMenu) container;
        for (int i = 0; i < jMenu.getItemCount(); i++) {
            JMenuItem mi = jMenu.getItem(i);
            mi.setFont(font);
        }
    }
}

From source file:Main.java

/**
 * Modifica fontul de la un label si il face bold
 * @param component/*from   w ww  . j  a  v  a  2 s.c o m*/
 */
public static void setFontBold(Component component) {
    Font oldFont = component.getFont();
    if (oldFont != null)
        component.setFont(oldFont.deriveFont(Font.BOLD));
}

From source file:Main.java

/**
 * Modifica fontul de la un label si il face bold
 * @param component/*from  www .  j  a v a  2 s  . c  o  m*/
 */
public static void setFontPlain(Component component) {
    Font oldFont = component.getFont();
    if (oldFont != null)
        component.setFont(oldFont.deriveFont(Font.PLAIN));
}

From source file:Main.java

private static void setFontStyle(Component c, int fontStyle) {
    Font newLabelFont = new Font(c.getFont().getName(), fontStyle, c.getFont().getSize());
    c.setFont(newLabelFont);
}