public class DefaultFontChooserModel extends AbstractFontChooserModel
Loading the fonts may take a lot of time. Therefore it is recommended to create a Future during the startup of an application, and set the fonts in the font chooser model when they are needed.
Example:
private static FutureTask future = new FutureTask(new Callable() { public Font[] call() throws Exception { return GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); } });
Modifier and Type | Class and Description |
---|---|
static class |
DefaultFontChooserModel.UIResource |
Modifier and Type | Field and Description |
---|---|
protected javax.swing.tree.DefaultMutableTreeNode |
root
Root node.
|
listenerList
Constructor and Description |
---|
DefaultFontChooserModel() |
DefaultFontChooserModel(java.awt.Font[] fonts) |
Modifier and Type | Method and Description |
---|---|
protected java.util.ArrayList<FontFamilyNode> |
collectFamiliesNamed(java.util.ArrayList<FontFamilyNode> families,
java.lang.String... names) |
java.lang.Object |
getChild(java.lang.Object parent,
int index) |
int |
getChildCount(java.lang.Object parent) |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child) |
java.lang.Object |
getRoot() |
boolean |
isEditable(javax.swing.tree.MutableTreeNode node)
Returns
true if node is editable by the user. |
boolean |
isLeaf(java.lang.Object node) |
void |
setFonts(java.awt.Font[] fonts)
Sets the fonts of the DefaultFontChooserModel.
|
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue) |
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeStructureChanged, getListeners, getTreeModelListeners, removeTreeModelListener
public DefaultFontChooserModel()
public DefaultFontChooserModel(java.awt.Font[] fonts)
public void setFonts(java.awt.Font[] fonts)
Fires treeStructureChanged event on the root node.
fonts
- protected java.util.ArrayList<FontFamilyNode> collectFamiliesNamed(java.util.ArrayList<FontFamilyNode> families, java.lang.String... names)
public boolean isEditable(javax.swing.tree.MutableTreeNode node)
FontChooserModel
true
if node
is editable by the user.
This method returns true, if the node and all its parents are editable.node
- a node in the tree, obtained from this data sourcenode
is editablepublic java.lang.Object getRoot()
public java.lang.Object getChild(java.lang.Object parent, int index)
public int getChildCount(java.lang.Object parent)
public boolean isLeaf(java.lang.Object node)
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)