Java Utililty Methods Swing Font

List of utility methods to do Swing Font

Description

The list of methods to do Swing Font are organized into topic(s).

Method

TmildFont(T comp)
mild Font
comp.setFont(comp.getFont().deriveFont(Font.PLAIN, 12f));
return comp;
JLabelmodifyLabelFont(JLabel label, int style, int delta)
modify Label Font
Font font = label.getFont();
label.setFont(font.deriveFont(style, font.getSize() + delta));
label.setForeground(new Color(140, 140, 140));
return label;
JLabelnewLabel(String text, int fontStyle)
new Label
JLabel label = new JLabel(text);
label.setFont(label.getFont().deriveFont(fontStyle));
return label;
voidrenderComponent(JComponent comp, Font f, Color foregroundColor, boolean opaque)
render Component
comp.setForeground(foregroundColor);
comp.setFont(f);
comp.setBackground(BG_COLOR);
comp.setOpaque(opaque);
voidrenderContainerComponents(JComponent comp, Font f, Color foregroundColor, Color backgroundColor)
render Container Components
for (Component c : getComponents(comp)) {
    c.setForeground(foregroundColor);
    c.setFont(f);
    c.setBackground(backgroundColor);
    ((JComponent) c).setOpaque(true);
voidscaleFontIfApplicable(javax.swing.UIDefaults uiDefaults, java.util.Map.Entry entry, double scale)
scale Font If Applicable
Object value = entry.getValue();
if (value instanceof javax.swing.UIDefaults.ActiveValue) {
    javax.swing.UIDefaults.ActiveValue activeValue = (javax.swing.UIDefaults.ActiveValue) value;
    value = activeValue.createValue(uiDefaults);
if (value instanceof javax.swing.plaf.FontUIResource) {
    scaleFontIfApplicable(uiDefaults, entry.getKey(), (javax.swing.plaf.FontUIResource) value, scale);
voidunBoldAllFonts()
un Bold All Fonts
UIManager.put("swing.boldMetal", Boolean.FALSE);
FontupdateFont(JComponent comp, Font f, boolean b)
update Font
return null;