public class FontChooser
extends javax.swing.JComponent
implements javax.swing.event.ListSelectionListener
Upon initialization, the FontChooser polls the system for all available fonts, initializes the various JList components to the values of the default font and provides a preview of the font. As options are changed or selected, the preview is updated to display the current font.
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected static float |
defaultSize
Default size
|
static java.lang.String |
PREVIEW_PANEL_PROPERTY
The preview panel property name.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
FontChooser()
Constructs a new FontChooser component initialized with the default font
(Arial).
|
FontChooser(java.awt.Font font)
Constructs a new FontChooser component initialized with the specified font.
|
Modifier and Type | Method and Description |
---|---|
static javax.swing.JDialog |
createDialog(java.awt.Component c,
java.lang.String title,
boolean modal,
FontChooser chooserPane,
java.awt.event.ActionListener okListener,
java.awt.event.ActionListener cancelListener)
Creates and returns a new dialog containing the specified
FontChooser pane along with "OK" and "Cancel" buttons. |
java.awt.Font |
getFont()
Get the currently selected font.
|
void |
setFont(java.awt.Font font)
Set the font that is currently being edited.
|
void |
setPreviewPanel(javax.swing.JLabel preview)
Sets the current preview panel.
|
static java.awt.Font |
showDialog(java.awt.Component component,
java.lang.String title,
java.awt.Font initialFont)
Shows a modal font-chooser dialog and blocks until the dialog is hidden.
|
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
Processes events received from the various JList objects.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getUIClassID, 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, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
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, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, 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, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected static final float defaultSize
public static final java.lang.String PREVIEW_PANEL_PROPERTY
public FontChooser()
public FontChooser(java.awt.Font font)
font
- The initial Font value to be set in the editor.public java.awt.Font getFont()
getFont
in interface java.awt.MenuContainer
getFont
in class java.awt.Component
public void setFont(java.awt.Font font)
setFont
in class javax.swing.JComponent
font
- The font value to be set.public void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in interface javax.swing.event.ListSelectionListener
e
- The list selection event.public static java.awt.Font showDialog(java.awt.Component component, java.lang.String title, java.awt.Font initialFont)
null
.component
- The parent Component
for the dialog.title
- The String containing the dialog's title.initialFont
- The initial Font set when the font-chooser is shown.public static javax.swing.JDialog createDialog(java.awt.Component c, java.lang.String title, boolean modal, FontChooser chooserPane, java.awt.event.ActionListener okListener, java.awt.event.ActionListener cancelListener)
FontChooser
pane along with "OK" and "Cancel" buttons. If the
"OK" or "Cancel" buttons are pressed, the dialog is automatically hidden
(but not disposed).c
- The parent component for the dialog.title
- The title for the dialog.modal
- A boolean. When true, the remainder of the program
is inactive until the dialog is closed.chooserPane
- The font-chooser to be placed inside the dialog.okListener
- The ActionListener invoked when "OK" is pressed.cancelListener
- The ActionListener invoked when "Cancel" is pressed.public void setPreviewPanel(javax.swing.JLabel preview)
PropertyChangeEvent
for the property
named "previewPanel".preview
- The preview panel to set.bound: true
hidden: true
description: The UI component which displays the current color.
Copyright © 2002 - 2010 Serva Software. All Rights Reserved.