List of usage examples for java.awt Component getFont
@Transient
public Font getFont()
From source file:Main.java
/** * Tries to derive a default header font from given context. * /*from w w w . ja v a 2s . co m*/ * @param context * @return */ public static Font deriveHeader2(Component context) { return context.getFont().deriveFont(Font.BOLD, 12); }
From source file:Main.java
/** * Tries to derive a default header font from given context. * /*w w w . ja va2s .c o m*/ * @param context * @return */ public static Font deriveHeader1(Component context) { return context.getFont().deriveFont(Font.PLAIN, 16); }
From source file:Main.java
public static FontMetrics getFontMetrics(Component component) { Font font = component.getFont(); if (font == null) { font = Font.getFont(Font.DIALOG); }//from www .ja va 2 s . com return component.getFontMetrics(font); }
From source file:Main.java
/** * Modifica fontul de la un label si il face bold * @param component//from w ww. ja va 2 s . c om */ 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 w w w . j a v a 2s. com */ public static void setFontPlain(Component component) { Font oldFont = component.getFont(); if (oldFont != null) component.setFont(oldFont.deriveFont(Font.PLAIN)); }
From source file:Main.java
public static void removeFontAttr(Component component, Object key) { Font original = component.getFont(); Map attributes = original.getAttributes(); attributes.remove(key);/*from w w w .j a v a 2 s.co m*/ component.setFont(original.deriveFont(attributes)); }
From source file:Main.java
/** * Change a component's Font size./*from ww w . j a v a2 s. co m*/ * <p> * The Font family and Font style are preserved in the updated Font. * @param component The component to change the Font presentation of. * @param size The new size of Font. * @return The new Font installed to the component. */ public static Font changeFontSize(Component component, float size) { Font existingFont = component.getFont(); Font newFont = existingFont.deriveFont(size); component.setFont(newFont); return newFont; }
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);//from w ww .j av a2 s . c om }
From source file:Main.java
/** * Returns whether component font is italic or not. * * @param component component to process * @return true if component font is italic, false otherwise *//* w w w . jav a 2 s .co m*/ public static boolean isItalicFont(final Component component) { return component != null && component.getFont() != null && component.getFont().isItalic(); }
From source file:Main.java
public static void setFontAttribute(Component component, Object key, Object value) { Font original = component.getFont(); Map attributes = original.getAttributes(); attributes.put(key, value);//from w ww. j a v a2s . c o m component.setFont(original.deriveFont(attributes)); }