public class FontCache
extends java.lang.Object
implements java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.awt.Font>>
Modifier and Type | Method and Description |
---|---|
void |
addFontChangeListener(FontChangeListener l)
Register a listener to be informed when the user changes font selections.
|
java.awt.Font |
getFont(java.lang.String category)
Get the font to use for a a particular GUI category.
|
static FontCache |
getInstance()
Get a reference to the singleton FontCache
|
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.awt.Font>> |
iterator()
Create an Iterator for scanning through the configured Fonts.
|
void |
removeFontChangeListener(FontChangeListener l)
Unregister a listener from being informed of user font selection changes.
|
void |
setFont(java.lang.String category,
java.awt.Font f)
Set the font to use for the logical font category.
|
static void |
setupJComponentForFonts(javax.swing.JComponent comp)
Helper method to configure an arbitrary JComponent to get its font updated when the
user font choice is changed.
|
static void |
setupJFrameForMenuFonts(javax.swing.JFrame frame)
Helper method for configuring a JFrame to use user-selected fonts for the menu bar.
|
public static FontCache getInstance()
public java.awt.Font getFont(java.lang.String category)
category
- Font family namepublic void setFont(java.lang.String category, java.awt.Font f)
category
- String name of font category, as taken from the constant Strings in the Font classf
- the Font to associate with the categorypublic java.util.Iterator<java.util.Map.Entry<java.lang.String,java.awt.Font>> iterator()
iterator
in interface java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.awt.Font>>
public void addFontChangeListener(FontChangeListener l)
l
- FontChangeListener to registerpublic void removeFontChangeListener(FontChangeListener l)
l
- FontChangeListener to unregisterpublic static void setupJFrameForMenuFonts(javax.swing.JFrame frame)
frame
- JFrame to initialize with configured sanserif fontpublic static void setupJComponentForFonts(javax.swing.JComponent comp)
comp
- JComponent to associate with configured font