|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent edu.princeton.wordnet.browser.component.JFontChooser
public class JFontChooser
The JFontChooser
class is a swing component for font selection. This class has JFileChooser
like APIs. The following code pops up a
font chooser dialog.
JFontChooser fontChooser = new JFontChooser(); int result = fontChooser.showDialog(parent); if (result == JFontChooser.OK_OPTION) { Font font = fontChooser.getSelectedFont(); System.out.println("Selected Font : " + font); }
Nested Class Summary | |
---|---|
protected class |
JFontChooser.DialogCancelAction
Dialog cancel action |
protected class |
JFontChooser.DialogOKAction
Dialog ok action |
protected class |
JFontChooser.ListSearchTextFieldDocumentHandler
Document handler |
protected class |
JFontChooser.ListSelectionHandler
List selection handler |
protected class |
JFontChooser.TextFieldFocusHandlerForTextSelection
Focus handler |
protected class |
JFontChooser.TextFieldKeyHandlerForListSelectionUpDown
Key handler |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
CANCEL_OPTION
Return value from showDialog() . |
private static java.awt.Font |
DEFAULT_FONT
Default font |
private static java.lang.String[] |
DEFAULT_FONT_SIZE_STRINGS
Font sizes |
private static java.awt.Font |
DEFAULT_SELECTED_FONT
Default selected font |
protected int |
dialogResultValue
Dialog result value |
static int |
ERROR_OPTION
Return value from showDialog() . |
private static int[] |
FONT_STYLE_CODES
Font styles |
private java.lang.String[] |
fontFamilyNames
|
private javax.swing.JTextField |
fontFamilyTextField
|
private javax.swing.JList |
fontNameList
|
private javax.swing.JPanel |
fontNamePanel
|
private javax.swing.JList |
fontSizeList
|
private javax.swing.JPanel |
fontSizePanel
|
private java.lang.String[] |
fontSizeStrings
|
private javax.swing.JTextField |
fontSizeTextField
|
private javax.swing.JList |
fontStyleList
|
private java.lang.String[] |
fontStyleNames
|
private javax.swing.JPanel |
fontStylePanel
|
private javax.swing.JTextField |
fontStyleTextField
|
static int |
OK_OPTION
Return value from showDialog() . |
private javax.swing.JPanel |
samplePanel
|
private javax.swing.JTextField |
sampleText
|
private static long |
serialVersionUID
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JFontChooser()
Constructs a JFontChooser object. |
|
JFontChooser(java.lang.String[] fontSizeStrings0)
Constructs a JFontChooser object using the given font size array. |
Method Summary | |
---|---|
protected java.lang.String |
_(java.lang.String key)
Localisation function |
protected javax.swing.JDialog |
createDialog(java.awt.Component parent)
Create dialog |
protected java.lang.String[] |
getFontFamilies()
Get font families |
javax.swing.JList |
getFontFamilyList()
Get font family list |
protected javax.swing.JPanel |
getFontFamilyPanel()
Get font family panel |
javax.swing.JTextField |
getFontFamilyTextField()
Get font family textfield |
javax.swing.JList |
getFontSizeList()
Get font size list |
protected javax.swing.JPanel |
getFontSizePanel()
Get font size panel |
javax.swing.JTextField |
getFontSizeTextField()
Get font size textfield |
javax.swing.JList |
getFontStyleList()
Get font size list |
protected java.lang.String[] |
getFontStyleNames()
Get font style names |
protected javax.swing.JPanel |
getFontStylePanel()
Get font style panel |
javax.swing.JTextField |
getFontStyleTextField()
Get font style textfield |
protected javax.swing.JPanel |
getSamplePanel()
Get sample panel |
protected javax.swing.JTextField |
getSampleTextField()
Get sample textfield |
java.awt.Font |
getSelectedFont()
Get the selected font. |
java.lang.String |
getSelectedFontFamily()
Get the family name of the selected font. |
int |
getSelectedFontSize()
Get the size of the selected font. |
int |
getSelectedFontStyle()
Get the style of the selected font. |
java.lang.String |
getVersionString()
Get localized "version" string |
void |
setSelectedFont(java.awt.Font font)
Set the selected font. |
void |
setSelectedFontFamily(java.lang.String name)
Set the family name of the selected font. |
void |
setSelectedFontSize(int size)
Set the size of the selected font. |
void |
setSelectedFontStyle(int style)
Set the style of the selected font. |
int |
showDialog(java.awt.Component parent)
Show font selection dialog. |
protected void |
updateSampleFont()
Update sample |
Methods inherited from class javax.swing.JComponent |
---|
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, updateUI |
Methods inherited from class java.awt.Container |
---|
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
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, hide, 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, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
public static final int OK_OPTION
showDialog()
.
showDialog(java.awt.Component)
,
Constant Field Valuespublic static final int CANCEL_OPTION
showDialog()
.
showDialog(java.awt.Component)
,
Constant Field Valuespublic static final int ERROR_OPTION
showDialog()
.
showDialog(java.awt.Component)
,
Constant Field Valuesprivate static final java.awt.Font DEFAULT_SELECTED_FONT
private static final java.awt.Font DEFAULT_FONT
private static final int[] FONT_STYLE_CODES
private static final java.lang.String[] DEFAULT_FONT_SIZE_STRINGS
protected int dialogResultValue
private java.lang.String[] fontStyleNames
private java.lang.String[] fontFamilyNames
private java.lang.String[] fontSizeStrings
private javax.swing.JTextField fontFamilyTextField
private javax.swing.JTextField fontStyleTextField
private javax.swing.JTextField fontSizeTextField
private javax.swing.JList fontNameList
private javax.swing.JList fontStyleList
private javax.swing.JList fontSizeList
private javax.swing.JPanel fontNamePanel
private javax.swing.JPanel fontStylePanel
private javax.swing.JPanel fontSizePanel
private javax.swing.JPanel samplePanel
private javax.swing.JTextField sampleText
Constructor Detail |
---|
public JFontChooser()
JFontChooser
object.
public JFontChooser(java.lang.String[] fontSizeStrings0)
JFontChooser
object using the given font size array.
fontSizeStrings0
- the array of font size string.Method Detail |
---|
protected java.lang.String _(java.lang.String key)
key
- key
public javax.swing.JTextField getFontFamilyTextField()
public javax.swing.JTextField getFontStyleTextField()
public javax.swing.JTextField getFontSizeTextField()
public javax.swing.JList getFontFamilyList()
public javax.swing.JList getFontStyleList()
public javax.swing.JList getFontSizeList()
public java.lang.String getSelectedFontFamily()
setSelectedFontFamily(java.lang.String)
public int getSelectedFontStyle()
Font.PLAIN
, Font.BOLD
, Font.ITALIC
, Font.BOLD|Font.ITALIC
Font.PLAIN
,
Font.BOLD
,
Font.ITALIC
,
setSelectedFontStyle(int)
public int getSelectedFontSize()
setSelectedFontSize(int)
public java.awt.Font getSelectedFont()
setSelectedFont(java.awt.Font)
,
Font
public void setSelectedFontFamily(java.lang.String name)
name
- the family name of the selected font.public void setSelectedFontStyle(int style)
style
- the size of the selected font. Font.PLAIN
, Font.BOLD
, Font.ITALIC
, or
Font.BOLD|Font.ITALIC
.Font.PLAIN
,
Font.BOLD
,
Font.ITALIC
,
getSelectedFontStyle()
public void setSelectedFontSize(int size)
size
- the size of the selected fontgetSelectedFontSize()
public void setSelectedFont(java.awt.Font font)
font
- the selected fontgetSelectedFont()
,
Font
public java.lang.String getVersionString()
public int showDialog(java.awt.Component parent)
parent
- Dialog's Parent component.
OK_OPTION
,
CANCEL_OPTION
,
ERROR_OPTION
protected javax.swing.JDialog createDialog(java.awt.Component parent)
parent
- parent
protected void updateSampleFont()
protected javax.swing.JPanel getFontFamilyPanel()
protected javax.swing.JPanel getFontStylePanel()
protected javax.swing.JPanel getFontSizePanel()
protected javax.swing.JPanel getSamplePanel()
protected javax.swing.JTextField getSampleTextField()
protected java.lang.String[] getFontFamilies()
protected java.lang.String[] getFontStyleNames()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |