public class JFontChooser extends JPanel
Font
.Font
,
Serialized FormJPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static String |
SELECTION_MODEL_PROPERTY
The selection model property name.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JFontChooser()
Creates a FontChooser pane with an initial default Font
(Sans Serif, Plain, 12).
|
JFontChooser(Font initialFont)
Creates a FontChooser pane with the specified initial Font.
|
JFontChooser(FontSelectionModel model)
Creates a FontChooser pane with the specified
FontSelectionModel . |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
Adds a
ChangeListener to the model. |
static JDialog |
createDialog(Window parent,
boolean modal,
JFontChooser chooserPane,
ActionListener okListener)
Creates and returns a new dialog containing the specified
FontChooser pane along with "OK" and "Cancel"
buttons. |
Font |
getSelectedFont()
Gets the current Font value from the FontChooser.
|
FontSelectionModel |
getSelectionModel()
Returns the data model that handles Font selections.
|
void |
removeChangeListener(ChangeListener l)
Removes a
ChangeListener from the model. |
void |
setSelectedFont(Font Font)
Sets the current Font of the FontChooser to the specified Font.
|
void |
setSelectionModel(FontSelectionModel newModel)
Sets the model containing the selected Font.
|
static Font |
showDialog(Window parent,
Font initialFont)
Shows a modal FontChooser dialog and blocks until the
dialog is hidden.
|
static Font |
showDialog(Window parent,
JFontChooser fontChooser,
Font initialFont)
Shows a modal FontChooser dialog and blocks until the
dialog is hidden.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final String SELECTION_MODEL_PROPERTY
public JFontChooser()
public JFontChooser(Font initialFont)
initialFont
- the initial Font set in the chooserpublic JFontChooser(FontSelectionModel model)
FontSelectionModel
.model
- the FontSelectionModel
to be usedpublic Font getSelectedFont()
public void setSelectedFont(Font Font)
FontSelectionModel
will fire a ChangeEvent
Font
- the Font to be set in the Font chooserContainer.addPropertyChangeListener(java.beans.PropertyChangeListener)
public FontSelectionModel getSelectionModel()
FontSelectionModel
objectpublic void setSelectionModel(FontSelectionModel newModel)
newModel
- the new FontSelectionModel
objectpublic static Font showDialog(Window parent, Font initialFont) throws HeadlessException
null
.parent
- the parent JFrame
for the dialoginitialFont
- the initial Font set when the FontChooser is shownnull
if the user opted outHeadlessException
- if GraphicsEnvironment.isHeadless()
returns true.GraphicsEnvironment.isHeadless()
public static Font showDialog(Window parent, JFontChooser fontChooser, Font initialFont) throws HeadlessException
null
.parent
- the parent JFrame
for the dialogfontChooser
- the FontChooser to be use in this dialoginitialFont
- the initial Font set when the FontChooser is shownnull
if the user opted outHeadlessException
- if GraphicsEnvironment.isHeadless()
returns true.GraphicsEnvironment.isHeadless()
public static JDialog createDialog(Window parent, boolean modal, JFontChooser chooserPane, ActionListener okListener) throws HeadlessException
FontChooser
pane along with "OK" and "Cancel"
buttons. If the "OK" or "Cancel" buttons are pressed, the dialog is
automatically hidden (but not disposed).parent
- the parent component for the dialogmodal
- 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 dialogokListener
- the ActionListener invoked when "OK" is pressedHeadlessException
- if GraphicsEnvironment.isHeadless()
returns true.GraphicsEnvironment.isHeadless()
public void addChangeListener(ChangeListener l)
ChangeListener
to the model.l
- the ChangeListener
to be addedpublic void removeChangeListener(ChangeListener l)
ChangeListener
from the model.l
- the ChangeListener
to be removed