public class FontSelector extends javax.swing.JComponent implements javax.swing.event.ListSelectionListener, javax.swing.event.ChangeListener, java.awt.event.ItemListener, java.awt.event.AdjustmentListener, ResourceComponentFactoryable
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected static java.awt.Font |
defaultFont
The default font.
|
protected static java.lang.String[] |
fontList |
protected java.awt.Font |
initialFont
The font that initalize the dialog.
|
protected java.awt.Font |
selectedFont
The selected font.
|
static java.lang.String |
SELECTEDFONT_PROPERTY
Property Name for the selected font.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
FontSelector()
The constructor.
|
FontSelector(java.awt.Font font,
PropertyBundle resources,
java.lang.String keySuffix,
boolean noBorder)
The constructor receive the initial font.
|
Modifier and Type | Method and Description |
---|---|
void |
addMenuItem(java.lang.String itemKey,
javax.swing.JMenuItem menuItem)
Register a menu item and its actions keyword.
|
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent e) |
java.beans.PropertyChangeListener |
createActionChangeListener(javax.swing.JMenuItem menuItem)
Creates an action changed listener that implements PropertyChangeListener
|
static javax.swing.JDialog |
createDialog(java.awt.Component c,
PropertyBundle resources,
boolean modal,
FontSelector dialogPane,
java.awt.event.ActionListener okListener,
java.awt.event.ActionListener cancelListener)
Creates and returns a new dialog containing the specified
ColorChooser pane along with "OK", "Cancel", and "Reset" buttons.
|
javax.swing.Action |
getAction(java.lang.String cmdKey)
Returns the menu item belongs the given keyword.
|
java.awt.Font |
getInitialFont()
Get the inital font.
|
protected java.lang.String |
getLocalKey(java.lang.String key) |
java.lang.String |
getResource(PropertyBundle resources,
java.lang.String key) |
java.awt.Font |
getSelectedFont()
Get the selected font.
|
FontSelectorUI |
getUI()
Returns the L&F object that renders this component.
|
java.lang.String |
getUIClassID()
Returns the name of the L&F class that renders this component.
|
void |
itemStateChanged(java.awt.event.ItemEvent e) |
void |
setInitialFont(java.awt.Font font)
Set the inital font.
|
void |
setInitialFont(java.lang.String n,
int sy,
int sz)
Set the initial font.
|
void |
setPreviewString(java.lang.String s)
Set the preview string.
|
void |
setSelectedFont(java.awt.Font font)
Set the selected font.
|
void |
setSelectedFont(java.lang.String n,
int sy,
int sz)
Set the selected font.
|
void |
setUI(FontSelectorUI ui)
Sets the L&F object that renders this component.
|
static java.awt.Font |
showDialog(java.awt.Component component,
java.awt.Font initialFont,
PropertyBundle resources,
java.lang.String keySuffix,
boolean noBorder)
Shows a modal font selector dialog and blocks until the
dialog is hidden.
|
void |
stateChanged(javax.swing.event.ChangeEvent e) |
java.lang.String |
toString()
Return the string representation of the selected font.
|
void |
updateUI()
Notification from the UIManager that the L&F has changed.
|
void |
valueChanged(javax.swing.event.ListSelectionEvent e) |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String SELECTEDFONT_PROPERTY
protected java.awt.Font initialFont
protected java.awt.Font selectedFont
protected static final java.awt.Font defaultFont
protected static final java.lang.String[] fontList
public FontSelector()
public FontSelector(java.awt.Font font, PropertyBundle resources, java.lang.String keySuffix, boolean noBorder)
public static java.awt.Font showDialog(java.awt.Component component, java.awt.Font initialFont, PropertyBundle resources, java.lang.String keySuffix, boolean noBorder)
component
- the parent Component for the dialoginitialFont
- the initial font when the selector is shownresources
- the resource component factory to configure the selector.propertySuffix
- the key suffix that should be used to find properties.public static javax.swing.JDialog createDialog(java.awt.Component c, PropertyBundle resources, boolean modal, FontSelector dialogPane, java.awt.event.ActionListener okListener, java.awt.event.ActionListener cancelListener)
c
- the parent component for the dialogtitle
- the title for the dialogmodal
- a boolean. When true, the remainder of the program
is inactive until the dialog is closed.chooserPane
- the color-chooser to be placed inside the dialogokListener
- the ActionListener invoked when "OK" is pressedcancelListener
- the ActionListener invoked when "Cancel" is pressedpublic FontSelectorUI getUI()
public void setUI(FontSelectorUI ui)
ui
- the FontSelectorUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
updateUI
in class javax.swing.JComponent
JComponent.updateUI()
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JComponent
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected java.lang.String getLocalKey(java.lang.String key)
public java.lang.String getResource(PropertyBundle resources, java.lang.String key)
public void stateChanged(javax.swing.event.ChangeEvent e)
stateChanged
in interface javax.swing.event.ChangeListener
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
adjustmentValueChanged
in interface java.awt.event.AdjustmentListener
public void itemStateChanged(java.awt.event.ItemEvent e)
itemStateChanged
in interface java.awt.event.ItemListener
public void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in interface javax.swing.event.ListSelectionListener
public java.lang.String toString()
toString
in class java.awt.Component
public java.awt.Font getSelectedFont()
public void setSelectedFont(java.awt.Font font)
font
- The new font.public void setSelectedFont(java.lang.String n, int sy, int sz)
n
- The family name of the font.sy
- The style of the font.sz
- The size of the font.public void setInitialFont(java.awt.Font font)
public void setInitialFont(java.lang.String n, int sy, int sz)
n
- The family name of the font.sy
- The style of the font.sz
- The size of the font.public java.awt.Font getInitialFont()
public void setPreviewString(java.lang.String s)
public void addMenuItem(java.lang.String itemKey, javax.swing.JMenuItem menuItem)
addMenuItem
in interface ResourceComponentFactoryable
public javax.swing.Action getAction(java.lang.String cmdKey)
getAction
in interface ResourceComponentFactoryable
public java.beans.PropertyChangeListener createActionChangeListener(javax.swing.JMenuItem menuItem)
createActionChangeListener
in interface ResourceComponentFactoryable