org.fife.ui
Class FontDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.fife.ui.FontDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListSelectionListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class FontDialog
extends javax.swing.JDialog
implements java.awt.event.ActionListener, javax.swing.event.ListSelectionListener

A dialog box that allows the user to choose from all fonts available to the application on the system, as well as choose a font color.

Version:
1.0
Author:
Robert Futrell
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FontDialog(java.awt.Dialog owner, java.lang.String title, java.awt.Font initialSelection, java.awt.Color initialColor)
          Creates a new font dialog from which the user can choose the font property "underline" and the font color.
FontDialog(java.awt.Dialog owner, java.lang.String title, java.awt.Font initialSelection, java.awt.Color initialColor, boolean underlineSelectable, boolean colorSelectable)
          Creates a new font dialog.
FontDialog(java.awt.Frame owner, java.lang.String title, java.awt.Font initialSelection, java.awt.Color initialColor)
          Creates a new font dialog from which the user can choose the font property "underline" and the font color.
FontDialog(java.awt.Frame owner, java.lang.String title, java.awt.Font initialSelection, java.awt.Color initialColor, boolean underlineSelectable, boolean colorSelectable)
          Creates a new font dialog.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 java.lang.String getFontLabel()
          Returns the label being used for the font list.
 java.lang.String getFontSampleLabel()
          Returns the label being used for the font sample area.
 java.lang.String getFontSampleText()
          Returns the text being used for the font sample.
 java.lang.String getFontSizeLabel()
          Returns the label being used for the font size list.
 java.lang.String getFontStyleLabel()
          Returns the label being used for the font style checkbox area.
 java.awt.Color getSelectedColor()
          Gets the color last chosen to use for fonts.
 java.awt.Font getSelectedFont()
          Gets the font last selected to use.
 boolean getUnderlineSelected()
          Returns whether or not the user checked the "Underline" check box.
 void setFontLabel(java.lang.String text)
          Sets the label being used for the font list.
 void setFontSampleLabel(java.lang.String text)
          Sets the label being used for the font sample area.
 void setFontSampleText(java.lang.String text)
          Sets the text being used for the font sample.
 void setFontSizeLabel(java.lang.String text)
          Sets the label to use for the font size list.
 void setFontStyleLabel(java.lang.String text)
          Sets the label to use for the font style checkbox area.
 void setSelectedFont(java.awt.Font toSelect, java.awt.Color color)
          Sets the currently selected font.
 void setUnderlineSelected(boolean underline)
          Sets or clears the "Underline" check box.
 void valueChanged(javax.swing.event.ListSelectionEvent e)
           
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FontDialog

public FontDialog(java.awt.Dialog owner,
                  java.lang.String title,
                  java.awt.Font initialSelection,
                  java.awt.Color initialColor)
Creates a new font dialog from which the user can choose the font property "underline" and the font color.

Parameters:
owner - The window for which you are picking a font.
title - The title of this dialog (e.g., "Font").
initialSelection - The font that this dialog initially has selected. A null value defaults to owner's font.
initialColor - The color to use for the font initially. A null value defaults to black.

FontDialog

public FontDialog(java.awt.Dialog owner,
                  java.lang.String title,
                  java.awt.Font initialSelection,
                  java.awt.Color initialColor,
                  boolean underlineSelectable,
                  boolean colorSelectable)
Creates a new font dialog.

Parameters:
owner - The window for which you are picking a font.
title - The title of this dialog (e.g., "Font").
initialSelection - The font that this dialog initially has selected. A null value defaults to owner's font.
initialColor - The color to use for the font initially. A null value defaults to black.
underlineSelectable - Whether or not the user can select "underline" as a property for the font being chosen.
colorSelectable - Whether or not the user can change the font's color from here.

FontDialog

public FontDialog(java.awt.Frame owner,
                  java.lang.String title,
                  java.awt.Font initialSelection,
                  java.awt.Color initialColor)
Creates a new font dialog from which the user can choose the font property "underline" and the font color.

Parameters:
owner - The window for which you are picking a font.
title - The title of this dialog (e.g., "Font").
initialSelection - The font that this dialog initially has selected. A null value defaults to owner's font.
initialColor - The color to use for the font initially. A null value defaults to black.

FontDialog

public FontDialog(java.awt.Frame owner,
                  java.lang.String title,
                  java.awt.Font initialSelection,
                  java.awt.Color initialColor,
                  boolean underlineSelectable,
                  boolean colorSelectable)
Creates a new font dialog.

Parameters:
owner - The window for which you are picking a font.
title - The title of this dialog (e.g., "Font").
initialSelection - The font that this dialog initially has selected. A null value defaults to owner's font.
initialColor - The color to use for the font initially. A null value defaults to black.
underlineSelectable - Whether or not the user can select "underline" as a property for the font being chosen.
colorSelectable - Whether or not the user can change the font's color from here.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getFontLabel

public final java.lang.String getFontLabel()
Returns the label being used for the font list.

Returns:
The label for the font list.
See Also:
setFontLabel(java.lang.String)

getFontSampleLabel

public final java.lang.String getFontSampleLabel()
Returns the label being used for the font sample area.

Returns:
The label for the font sample area.
See Also:
setFontSampleLabel(java.lang.String)

getFontSampleText

public final java.lang.String getFontSampleText()
Returns the text being used for the font sample.

Returns:
The text being used for the font sample.
See Also:
setFontSampleText(java.lang.String)

getFontSizeLabel

public final java.lang.String getFontSizeLabel()
Returns the label being used for the font size list.

Returns:
The label for the font size list.
See Also:
setFontSizeLabel(java.lang.String)

getFontStyleLabel

public final java.lang.String getFontStyleLabel()
Returns the label being used for the font style checkbox area.

Returns:
The label for the font style checkbox area.
See Also:
setFontStyleLabel(java.lang.String)

getSelectedColor

public java.awt.Color getSelectedColor()
Gets the color last chosen to use for fonts.

Returns:
The color to use for the current font, or null if the dialog was canceled.

getSelectedFont

public java.awt.Font getSelectedFont()
Gets the font last selected to use.

Returns:
The font to use for the current font, or null if the dialog was canceled.
See Also:
getUnderlineSelected()

getUnderlineSelected

public boolean getUnderlineSelected()
Returns whether or not the user checked the "Underline" check box. Note that if this dialog was created such that "Underline" is not selectable, this method will always return false.

Returns:
Whether or not "underline" was selected.
See Also:
setUnderlineSelected(boolean)

setFontLabel

public void setFontLabel(java.lang.String text)
Sets the label being used for the font list.

Parameters:
text - The label for the font list.
See Also:
getFontLabel()

setFontSampleLabel

public void setFontSampleLabel(java.lang.String text)
Sets the label being used for the font sample area.

Parameters:
text - The label for the font sample area.
See Also:
getFontSampleLabel()

setFontSampleText

public void setFontSampleText(java.lang.String text)
Sets the text being used for the font sample.

Parameters:
text - The text to use for the font sample.
See Also:
getFontSampleText()

setFontSizeLabel

public void setFontSizeLabel(java.lang.String text)
Sets the label to use for the font size list.

Parameters:
text - The label to usefor the font size list.
See Also:
getFontSizeLabel()

setFontStyleLabel

public void setFontStyleLabel(java.lang.String text)
Sets the label to use for the font style checkbox area.

Parameters:
text - The label for the font style checkbox area.
See Also:
getFontStyleLabel()

setSelectedFont

public void setSelectedFont(java.awt.Font toSelect,
                            java.awt.Color color)
Sets the currently selected font.

Parameters:
toSelect - The new currently-selected font.
color - The color to use as the font color.

setUnderlineSelected

public void setUnderlineSelected(boolean underline)
Sets or clears the "Underline" check box. Note that if this dialog was created such that "Underline" is not selectable, this method does nothing.

Parameters:
underline - Whether or not the Underline check box should be selected.
See Also:
getUnderlineSelected()

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener