edu.princeton.wordnet.browser.component
Class JFontChooser

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by edu.princeton.wordnet.browser.component.JFontChooser
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JFontChooser
extends javax.swing.JComponent

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);
 }
 
 

See Also:
Serialized Form

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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

OK_OPTION

public static final int OK_OPTION
Return value from showDialog().

See Also:
showDialog(java.awt.Component), Constant Field Values

CANCEL_OPTION

public static final int CANCEL_OPTION
Return value from showDialog().

See Also:
showDialog(java.awt.Component), Constant Field Values

ERROR_OPTION

public static final int ERROR_OPTION
Return value from showDialog().

See Also:
showDialog(java.awt.Component), Constant Field Values

DEFAULT_SELECTED_FONT

private static final java.awt.Font DEFAULT_SELECTED_FONT
Default selected font


DEFAULT_FONT

private static final java.awt.Font DEFAULT_FONT
Default font


FONT_STYLE_CODES

private static final int[] FONT_STYLE_CODES
Font styles


DEFAULT_FONT_SIZE_STRINGS

private static final java.lang.String[] DEFAULT_FONT_SIZE_STRINGS
Font sizes


dialogResultValue

protected int dialogResultValue
Dialog result value


fontStyleNames

private java.lang.String[] fontStyleNames

fontFamilyNames

private java.lang.String[] fontFamilyNames

fontSizeStrings

private java.lang.String[] fontSizeStrings

fontFamilyTextField

private javax.swing.JTextField fontFamilyTextField

fontStyleTextField

private javax.swing.JTextField fontStyleTextField

fontSizeTextField

private javax.swing.JTextField fontSizeTextField

fontNameList

private javax.swing.JList fontNameList

fontStyleList

private javax.swing.JList fontStyleList

fontSizeList

private javax.swing.JList fontSizeList

fontNamePanel

private javax.swing.JPanel fontNamePanel

fontStylePanel

private javax.swing.JPanel fontStylePanel

fontSizePanel

private javax.swing.JPanel fontSizePanel

samplePanel

private javax.swing.JPanel samplePanel

sampleText

private javax.swing.JTextField sampleText
Constructor Detail

JFontChooser

public JFontChooser()
Constructs a JFontChooser object.


JFontChooser

public JFontChooser(java.lang.String[] fontSizeStrings0)
Constructs a JFontChooser object using the given font size array.

Parameters:
fontSizeStrings0 - the array of font size string.
Method Detail

_

protected java.lang.String _(java.lang.String key)
Localisation function

Parameters:
key - key
Returns:
string value

getFontFamilyTextField

public javax.swing.JTextField getFontFamilyTextField()
Get font family textfield

Returns:
font family textfield

getFontStyleTextField

public javax.swing.JTextField getFontStyleTextField()
Get font style textfield

Returns:
font style textfield

getFontSizeTextField

public javax.swing.JTextField getFontSizeTextField()
Get font size textfield

Returns:
font size textfield

getFontFamilyList

public javax.swing.JList getFontFamilyList()
Get font family list

Returns:
font family list

getFontStyleList

public javax.swing.JList getFontStyleList()
Get font size list

Returns:
font size list

getFontSizeList

public javax.swing.JList getFontSizeList()
Get font size list

Returns:
font size list

getSelectedFontFamily

public java.lang.String getSelectedFontFamily()
Get the family name of the selected font.

Returns:
the font family of the selected font.
See Also:
setSelectedFontFamily(java.lang.String)

getSelectedFontStyle

public int getSelectedFontStyle()
Get the style of the selected font.

Returns:
the style of the selected font. Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD|Font.ITALIC
See Also:
Font.PLAIN, Font.BOLD, Font.ITALIC, setSelectedFontStyle(int)

getSelectedFontSize

public int getSelectedFontSize()
Get the size of the selected font.

Returns:
the size of the selected font
See Also:
setSelectedFontSize(int)

getSelectedFont

public java.awt.Font getSelectedFont()
Get the selected font.

Returns:
the selected font
See Also:
setSelectedFont(java.awt.Font), Font

setSelectedFontFamily

public void setSelectedFontFamily(java.lang.String name)
Set the family name of the selected font.

Parameters:
name - the family name of the selected font.

setSelectedFontStyle

public void setSelectedFontStyle(int style)
Set the style of the selected font.

Parameters:
style - the size of the selected font. Font.PLAIN, Font.BOLD, Font.ITALIC, or Font.BOLD|Font.ITALIC.
See Also:
Font.PLAIN, Font.BOLD, Font.ITALIC, getSelectedFontStyle()

setSelectedFontSize

public void setSelectedFontSize(int size)
Set the size of the selected font.

Parameters:
size - the size of the selected font
See Also:
getSelectedFontSize()

setSelectedFont

public void setSelectedFont(java.awt.Font font)
Set the selected font.

Parameters:
font - the selected font
See Also:
getSelectedFont(), Font

getVersionString

public java.lang.String getVersionString()
Get localized "version" string

Returns:
localized "version" string

showDialog

public int showDialog(java.awt.Component parent)
Show font selection dialog.

Parameters:
parent - Dialog's Parent component.
Returns:
OK_OPTION, CANCEL_OPTION or ERROR_OPTION
See Also:
OK_OPTION, CANCEL_OPTION, ERROR_OPTION

createDialog

protected javax.swing.JDialog createDialog(java.awt.Component parent)
Create dialog

Parameters:
parent - parent
Returns:
dialog

updateSampleFont

protected void updateSampleFont()
Update sample


getFontFamilyPanel

protected javax.swing.JPanel getFontFamilyPanel()
Get font family panel

Returns:
font family panel

getFontStylePanel

protected javax.swing.JPanel getFontStylePanel()
Get font style panel

Returns:
font style panel

getFontSizePanel

protected javax.swing.JPanel getFontSizePanel()
Get font size panel

Returns:
font size panel

getSamplePanel

protected javax.swing.JPanel getSamplePanel()
Get sample panel

Returns:
sample panel

getSampleTextField

protected javax.swing.JTextField getSampleTextField()
Get sample textfield

Returns:
sample textfield

getFontFamilies

protected java.lang.String[] getFontFamilies()
Get font families

Returns:
font families

getFontStyleNames

protected java.lang.String[] getFontStyleNames()
Get font style names

Returns:
font style names