Quaqua 5.4.1 2009-07-14

ch.randelshofer.quaqua
Class Quaqua14FormattedTextFieldUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TextUI
          extended by javax.swing.plaf.basic.BasicTextUI
              extended by javax.swing.plaf.basic.BasicTextFieldUI
                  extended by javax.swing.plaf.basic.BasicFormattedTextFieldUI
                      extended by ch.randelshofer.quaqua.Quaqua14FormattedTextFieldUI
All Implemented Interfaces:
VisuallyLayoutable, javax.swing.text.ViewFactory

public class Quaqua14FormattedTextFieldUI
extends javax.swing.plaf.basic.BasicFormattedTextFieldUI
implements VisuallyLayoutable

Quaqua14FormattedTextFieldUI.

Version:
1.6.2 2009-04-03 Paint the background color if no background border is present.
1.6.1 2009-02-16 Override method paintBackground to make it do nothing.
1.6 2007-08-06 Select all text when the user tabs into the field.
1.5 2007-07-27 Added 2 pixels to the preferred width.
1.4 2006-04-24 Added support for .popupHandler UIManager property. Fixed .opaque UIManager property.
1.3 2005-10-01 Tweaked due to changes in QuaquaTreeUI. Non-opaque background painting delegated to QuaquaTextFieldBorder.
1.2 2005-07-17 Adapted to changes in interface VisuallyLayoutable.
1.1 2005-02-27 Support for margin added.
1.0 06 March 2005 Created.
Author:
Werner Randelshofer

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTextUI
javax.swing.plaf.basic.BasicTextUI.BasicCaret, javax.swing.plaf.basic.BasicTextUI.BasicHighlighter
 
Field Summary
 
Fields inherited from interface ch.randelshofer.quaqua.VisuallyLayoutable
CLIP_BOUNDS, COMPONENT_BOUNDS, TEXT_BOUNDS
 
Constructor Summary
Quaqua14FormattedTextFieldUI()
           
 
Method Summary
protected  javax.swing.text.Caret createCaret()
           
protected  java.awt.event.FocusListener createFocusListener()
           
protected  javax.swing.text.Highlighter createHighlighter()
           
protected  javax.swing.text.Keymap createKeymap()
          Creates the keymap to use for the text component, and installs any necessary bindings into it.
protected  java.awt.event.MouseListener createPopupListener()
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
          Creates a UI for a JFormattedTextField.
 int getBaseline(javax.swing.JComponent c, int width, int height)
          Returns the baseline for the specified component, or -1 if the baseline can not be determined.
 javax.swing.text.EditorKit getEditorKit(javax.swing.text.JTextComponent tc)
          Fetches the EditorKit for the UI.
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
           
 java.awt.Rectangle getVisualBounds(javax.swing.JComponent c, int type, int width, int height)
          Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.
 java.awt.Insets getVisualMargin(javax.swing.text.JTextComponent tc)
           
protected  void installDefaults()
           
protected  void installListeners()
           
 void installUI(javax.swing.JComponent c)
           
protected  void paintBackground(java.awt.Graphics g)
          Paints a background for the view.
protected  void paintSafely(java.awt.Graphics g)
           
 void propertyChange(java.beans.PropertyChangeEvent event)
           
protected  void uninstallDefaults()
           
protected  void uninstallListeners()
           
 
Methods inherited from class javax.swing.plaf.basic.BasicFormattedTextFieldUI
getPropertyPrefix
 
Methods inherited from class javax.swing.plaf.basic.BasicTextFieldUI
create
 
Methods inherited from class javax.swing.plaf.basic.BasicTextUI
create, damageRange, damageRange, getComponent, getKeymapName, getMaximumSize, getMinimumSize, getNextVisualPositionFrom, getRootView, getToolTipText, getVisibleEditorRect, installKeyboardActions, modelChanged, modelToView, modelToView, paint, setView, uninstallKeyboardActions, uninstallUI, update, viewToModel, viewToModel
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Quaqua14FormattedTextFieldUI

public Quaqua14FormattedTextFieldUI()
Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
Creates a UI for a JFormattedTextField.

Parameters:
c - the formatted text field
Returns:
the UI

installUI

public void installUI(javax.swing.JComponent c)
Overrides:
installUI in class javax.swing.plaf.basic.BasicTextFieldUI

installDefaults

protected void installDefaults()
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicTextUI

uninstallDefaults

protected void uninstallDefaults()
Overrides:
uninstallDefaults in class javax.swing.plaf.basic.BasicTextUI

installListeners

protected void installListeners()
Overrides:
installListeners in class javax.swing.plaf.basic.BasicTextUI

uninstallListeners

protected void uninstallListeners()
Overrides:
uninstallListeners in class javax.swing.plaf.basic.BasicTextUI

createFocusListener

protected java.awt.event.FocusListener createFocusListener()

createPopupListener

protected java.awt.event.MouseListener createPopupListener()

getEditorKit

public javax.swing.text.EditorKit getEditorKit(javax.swing.text.JTextComponent tc)
Fetches the EditorKit for the UI.

Overrides:
getEditorKit in class javax.swing.plaf.basic.BasicTextUI
Parameters:
tc - the text component for which this UI is installed
Returns:
the editor capabilities
See Also:
TextUI.getEditorKit(javax.swing.text.JTextComponent)

getVisualMargin

public java.awt.Insets getVisualMargin(javax.swing.text.JTextComponent tc)

paintSafely

protected void paintSafely(java.awt.Graphics g)
Overrides:
paintSafely in class javax.swing.plaf.basic.BasicTextUI

paintBackground

protected void paintBackground(java.awt.Graphics g)
Paints a background for the view. This will only be called if isOpaque() on the associated component is true. The default is to paint the background color of the component.

Overrides:
paintBackground in class javax.swing.plaf.basic.BasicTextUI
Parameters:
g - the graphics context

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Overrides:
propertyChange in class javax.swing.plaf.basic.BasicTextFieldUI

createCaret

protected javax.swing.text.Caret createCaret()
Overrides:
createCaret in class javax.swing.plaf.basic.BasicTextUI

createHighlighter

protected javax.swing.text.Highlighter createHighlighter()
Overrides:
createHighlighter in class javax.swing.plaf.basic.BasicTextUI

createKeymap

protected javax.swing.text.Keymap createKeymap()
Creates the keymap to use for the text component, and installs any necessary bindings into it. By default, the keymap is shared between all instances of this type of TextUI. The keymap has the name defined by the getKeymapName method. If the keymap is not found, then DEFAULT_KEYMAP from JTextComponent is used.

The set of bindings used to create the keymap is fetched from the UIManager using a key formed by combining the BasicFormattedTextFieldUI.getPropertyPrefix() method and the name .keyBindings. The type is expected to be JTextComponent.KeyBinding[].

Overrides:
createKeymap in class javax.swing.plaf.basic.BasicTextUI
Returns:
the keymap
See Also:
BasicTextUI.getKeymapName(), JTextComponent

getBaseline

public int getBaseline(javax.swing.JComponent c,
                       int width,
                       int height)
Description copied from interface: VisuallyLayoutable
Returns the baseline for the specified component, or -1 if the baseline can not be determined. The baseline is measured from the top of the component.

Specified by:
getBaseline in interface VisuallyLayoutable
Parameters:
c - JComponent to calculate baseline for
width - Width of the component to determine baseline for.
height - Height of the component to determine baseline for.
Returns:
baseline for the specified component

getVisualBounds

public java.awt.Rectangle getVisualBounds(javax.swing.JComponent c,
                                          int type,
                                          int width,
                                          int height)
Description copied from interface: VisuallyLayoutable
Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.

Specified by:
getVisualBounds in interface VisuallyLayoutable
Parameters:
c - JComponent to calculate visual margin for
type - The type of the visual margin.
width - Width of the component
height - Height of the component
Returns:
The visual bounds in component coordinates.

getPreferredSize

public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
Overrides:
getPreferredSize in class javax.swing.plaf.basic.BasicTextUI

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.