public class DefaultFontSelectionModel extends Object implements FontSelectionModel
FontSelectionModel.Font| Modifier and Type | Field and Description |
|---|---|
protected ChangeEvent |
changeEvent
Only one
ChangeEvent is needed per model instance
since the event's only (read-only) state is the source property. |
protected EventListenerList |
listenerList
A list of registered event listeners.
|
| Constructor and Description |
|---|
DefaultFontSelectionModel()
Creates a
DefaultFontSelectionModel with the
current font set to new Font(Font.SANS_SERIF, Font.PLAIN, 12)
. |
DefaultFontSelectionModel(Font font)
Creates a
DefaultFontSelectionModel with the
current font set to font, which should be
non-null. |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener l)
Adds a
ChangeListener to the model. |
protected void |
fireStateChanged()
Runs each
ChangeListener's
stateChanged method. |
List<String> |
getAvailableFontNames()
Gets the available font names.
|
ChangeListener[] |
getChangeListeners()
Returns an array of all the
ChangeListeners added
to this DefaultFontSelectionModel with
addChangeListener. |
Font |
getSelectedFont()
Returns the selected
Font which should be
non-null. |
void |
removeChangeListener(ChangeListener l)
Removes a
ChangeListener from the model. |
void |
setSelectedFont(Font font)
Sets the selected font to
font. |
protected transient ChangeEvent changeEvent
ChangeEvent is needed per model instance
since the event's only (read-only) state is the source property.
The source of events generated here is always "this".protected EventListenerList listenerList
public DefaultFontSelectionModel()
DefaultFontSelectionModel with the
current font set to new Font(Font.SANS_SERIF, Font.PLAIN, 12)
. This is the default constructor.public DefaultFontSelectionModel(Font font)
DefaultFontSelectionModel with the
current font set to font, which should be
non-null. Note that setting the font to
null is undefined and may have unpredictable
results.font - the new Fontpublic Font getSelectedFont()
Font which should be
non-null.getSelectedFont in interface FontSelectionModelFontFontSelectionModel.setSelectedFont(java.awt.Font)public void setSelectedFont(Font font)
font.
Note that setting the font to null
is undefined and may have unpredictable results.
This method fires a state changed event if it sets the
current font to a new non-null font;
if the new font is the same as the current font,
no event is fired.setSelectedFont in interface FontSelectionModelfont - the new FontFontSelectionModel.getSelectedFont(),
FontSelectionModel.addChangeListener(javax.swing.event.ChangeListener)public List<String> getAvailableFontNames()
GraphicsEnvironment localized for the default locale,
as returned by Locale.getDefault().getAvailableFontNames in interface FontSelectionModelpublic void addChangeListener(ChangeListener l)
ChangeListener to the model.addChangeListener in interface FontSelectionModell - the ChangeListener to be addedpublic void removeChangeListener(ChangeListener l)
ChangeListener from the model.removeChangeListener in interface FontSelectionModell - the ChangeListener to be removedpublic ChangeListener[] getChangeListeners()
ChangeListeners added
to this DefaultFontSelectionModel with
addChangeListener.ChangeListeners added, or an empty
array if no listeners have been addedprotected void fireStateChanged()
ChangeListener's
stateChanged method.