APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicTextFieldUI

extends BasicTextUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.metal.MetalTextFieldUI, javax.swing.plaf.synth.SynthTextFieldUI, com.sun.java.swing.plaf.motif.MotifTextFieldUI, javax.swing.plaf.basic.BasicFormattedTextFieldUI, javax.swing.plaf.basic.BasicPasswordFieldUI
Imports
java.awt.*, java.awt.event.KeyEvent, .FocusEvent, .InputEvent, java.beans.PropertyChangeEvent, java.io.Reader, javax.swing.*, javax.swing.border.*, javax.swing.event.*, javax.swing.text.*, javax.swing.plaf.*, sun.swing.DefaultLookup

Basis of a look and feel for a JTextField.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
Timothy Prinzing

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
BasicTextFieldUI.I18nFieldView

A field view that support bidirectional text via the support provided by ParagraphView.

Field Summary

Inherited from javax.swing.plaf.basic.BasicTextUI:
editorpaintedrootViewupdateHandler

Constructor Summary

AccessConstructor and Description
public
BasicTextFieldUI()

Creates a new BasicTextFieldUI.

Method Summary

Modifier and TypeMethod and Description
public View

Returns:

the view for the element
create
(Element
the element
elem
)

Overrides javax.swing.plaf.basic.BasicTextUI.create.

Implements javax.swing.text.ViewFactory.create.

Creates a view for an element.

public static ComponentUI

Returns:

the UI
createUI
(JComponent
the text field
c
)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a UI for a JTextField.

public int
getBaseline(JComponent c, int width, int height)

Overrides javax.swing.plaf.ComponentUI.getBaseline.

Returns the baseline.

public Component.BaselineResizeBehavior
getBaselineResizeBehavior(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getBaselineResizeBehavior.

Returns an enum indicating how the baseline of the component changes as the size changes.

protected String

Returns:

the name ("TextField")
getPropertyPrefix
()

Implements abstract javax.swing.plaf.basic.BasicTextUI.getPropertyPrefix.

Fetches the name used as a key to lookup properties through the UIManager.

Inherited from javax.swing.plaf.basic.BasicTextUI:
createcreateActionMapcreateCaretcreateHighlightercreateKeymapdamageRangedamageRangegetActionMapgetComponentgetEditorKitgetInputMapgetKeymapNamegetMaximumSizegetMinimumSizegetNextVisualPositionFromgetPreferredSizegetRootViewgetToolTipTextgetTransferHandlergetVisibleEditorRectinstallDefaultsinstallKeyboardActionsinstallListenersinstallUImodelChangedmodelToViewmodelToViewmodelToView2DpaintpaintBackgroundpaintSafelypropertyChangesetViewuninstallDefaultsuninstallKeyboardActionsuninstallListenersuninstallUIupdateupdateFocusAcceleratorBindingupdateFocusTraversalKeysviewToModelviewToModelviewToModel2D

Constructor Detail

BasicTextFieldUIback to summary
public BasicTextFieldUI()

Creates a new BasicTextFieldUI.

Method Detail

createback to summary
public View create(Element elem)

Overrides javax.swing.plaf.basic.BasicTextUI.create.

Implements javax.swing.text.ViewFactory.create.

Creates a view for an element.

Parameters
elem:Element

the element

Returns:View

the view for the element

createUIback to summary
public static ComponentUI createUI(JComponent c)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a UI for a JTextField.

Parameters
c:JComponent

the text field

Returns:ComponentUI

the UI

getBaselineback to summary
public int getBaseline(JComponent c, int width, int height)

Overrides javax.swing.plaf.ComponentUI.getBaseline.

Returns the baseline.

Exceptions
NullPointerException:
if c is null
IllegalArgumentException:
if width or height is < 0
Since
1.6
See Also
javax.swing.JComponent#getBaseline(int, int)
getBaselineResizeBehaviorback to summary
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getBaselineResizeBehavior.

Returns an enum indicating how the baseline of the component changes as the size changes.

Exceptions
NullPointerException:
if c is null
Since
1.6
See Also
javax.swing.JComponent#getBaseline(int, int)
getPropertyPrefixback to summary
protected String getPropertyPrefix()

Implements abstract javax.swing.plaf.basic.BasicTextUI.getPropertyPrefix.

Fetches the name used as a key to lookup properties through the UIManager. This is used as a prefix to all the standard text properties.

Returns:String

the name ("TextField")

javax.swing.plaf.basic back to summary

pack-priv Class BasicTextFieldUI.I18nFieldView

extends ParagraphView
Class Inheritance

A field view that support bidirectional text via the support provided by ParagraphView.

Field Summary

Inherited from javax.swing.text.ParagraphView:
firstLineIndent

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Shape

Returns:

the allocation that the superclass should use.
adjustAllocation
(Shape
the allocation given to the view, which may need to be adjusted.
a
)

Adjusts the allocation given to the view to be a suitable allocation for a text field.

public int
getFlowSpan(int index)

Overrides javax.swing.text.ParagraphView.getFlowSpan.

Fetch the constraining span to flow against for the given child index.

public int

Returns:

the weight -> 1 for View.X_AXIS, else 0
getResizeWeight
(int
View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.BoxView.getResizeWeight.

Determines the resizability of the view along the given axis.

public void
insertUpdate(DocumentEvent
the change information from the associated document
changes
,
Shape
the current allocation of the view
a
,
ViewFactory
the factory to use to rebuild if the view has children
f
)

Overrides javax.swing.text.FlowView.insertUpdate.

Gives notification that something was inserted into the document in a location that this view is responsible for.

pack-priv static boolean
public Shape

Returns:

the bounding box of the given position
modelToView
(int
the position to convert >= 0
pos
,
Shape
the allocated region to render into
a
,
Position.Bias b)

Overrides javax.swing.text.BoxView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

public Shape

Returns:

the bounding box of the given position is returned
modelToView
(int
the position to convert >= 0
p0
,
Position.Bias
the bias toward the previous character or the next character represented by p0, in case the position is a boundary of two views.
b0
,
int
the position to convert >= 0
p1
,
Position.Bias
the bias toward the previous character or the next character represented by p1, in case the position is a boundary of two views.
b1
,
Shape
the allocated region to render into
a
)

Overrides javax.swing.text.CompositeView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

public void
paint(Graphics
the rendering surface to use
g
,
Shape
the allocated region to render into
a
)

Overrides javax.swing.text.ParagraphView.paint.

Renders using the given rendering surface and area on that surface.

public void
removeUpdate(DocumentEvent
the change information from the associated document
changes
,
Shape
the current allocation of the view
a
,
ViewFactory
the factory to use to rebuild if the view has children
f
)

Overrides javax.swing.text.FlowView.removeUpdate.

Gives notification that something was removed from the document in a location that this view is responsible for.

protected void
setJustification(int j)

Overrides javax.swing.text.ParagraphView.setJustification.

Sets the type of justification.

pack-priv void
updateVisibilityModel()

Update the visibility model with the associated JTextField (if there is one) to reflect the current visibility as a result of changes to the document model.

public int

Returns:

the location within the model that best represents the given point in the view
viewToModel
(float
the X coordinate >= 0.0f
fx
,
float
the Y coordinate >= 0.0f
fy
,
Shape
the allocated region to render into
a
,
Position.Bias[] bias)

Overrides javax.swing.text.BoxView.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Inherited from javax.swing.text.ParagraphView:
breakViewcalculateMinorAxisRequirementschangedUpdatecreateRowfindOffsetToCharactersInStringflipEastAndWestAtEndsgetAlignmentgetBreakWeightgetClosestPositionTogetFlowStartgetLayoutViewgetLayoutViewCountgetNextNorthSouthVisualPositionFromgetPartialSizegetTabBasegetTabSetnextTabStopsetFirstLineIndentsetLineSpacingsetPropertiesFromAttributes

Constructor Detail

I18nFieldViewback to summary
pack-priv I18nFieldView(Element elem)

Method Detail

adjustAllocationback to summary
pack-priv Shape adjustAllocation(Shape a)

Adjusts the allocation given to the view to be a suitable allocation for a text field. If the view has been allocated more than the preferred span vertically, the allocation is changed to be centered vertically. Horizontally the view is adjusted according to the horizontal alignment property set on the associated JTextField (if that is the type of the hosting component).

Parameters
a:Shape

the allocation given to the view, which may need to be adjusted.

Returns:Shape

the allocation that the superclass should use.

getFlowSpanback to summary
public int getFlowSpan(int index)

Overrides javax.swing.text.ParagraphView.getFlowSpan.

Fetch the constraining span to flow against for the given child index. There is no limit for a field since it scrolls, so this is implemented to return Integer.MAX_VALUE.

getResizeWeightback to summary
public int getResizeWeight(int axis)

Overrides javax.swing.text.BoxView.getResizeWeight.

Determines the resizability of the view along the given axis. A value of 0 or less is not resizable.

Parameters
axis:int

View.X_AXIS or View.Y_AXIS

Returns:int

the weight -> 1 for View.X_AXIS, else 0

insertUpdateback to summary
public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f)

Overrides javax.swing.text.FlowView.insertUpdate.

Gives notification that something was inserted into the document in a location that this view is responsible for.

Parameters
changes:DocumentEvent

the change information from the associated document

a:Shape

the current allocation of the view

f:ViewFactory

the factory to use to rebuild if the view has children

See Also
View#insertUpdate
isLeftToRightback to summary
pack-priv static boolean isLeftToRight(Component c)
modelToViewback to summary
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException

Overrides javax.swing.text.BoxView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters
pos:int

the position to convert >= 0

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
See Also
View#modelToView
modelToViewback to summary
public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a) throws BadLocationException

Overrides javax.swing.text.CompositeView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters
p0:int

the position to convert >= 0

b0:Position.Bias

the bias toward the previous character or the next character represented by p0, in case the position is a boundary of two views.

p1:int

the position to convert >= 0

b1:Position.Bias

the bias toward the previous character or the next character represented by p1, in case the position is a boundary of two views.

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position is returned

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
IllegalArgumentException:
for an invalid bias argument
See Also
View#viewToModel
paintback to summary
public void paint(Graphics g, Shape a)

Overrides javax.swing.text.ParagraphView.paint.

Renders using the given rendering surface and area on that surface. The view may need to do layout and create child views to enable itself to render into the given allocation.

Parameters
g:Graphics

the rendering surface to use

a:Shape

the allocated region to render into

See Also
View#paint
removeUpdateback to summary
public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f)

Overrides javax.swing.text.FlowView.removeUpdate.

Gives notification that something was removed from the document in a location that this view is responsible for.

Parameters
changes:DocumentEvent

the change information from the associated document

a:Shape

the current allocation of the view

f:ViewFactory

the factory to use to rebuild if the view has children

See Also
View#removeUpdate
setJustificationback to summary
protected void setJustification(int j)

Overrides javax.swing.text.ParagraphView.setJustification.

Doc from javax.swing.text.ParagraphView.setJustification.

Sets the type of justification.

updateVisibilityModelback to summary
pack-priv void updateVisibilityModel()

Update the visibility model with the associated JTextField (if there is one) to reflect the current visibility as a result of changes to the document model. The bounded range properties are updated. If the view hasn't yet been shown the extent will be zero and we just set it to be full until determined otherwise.

viewToModelback to summary
public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias)

Overrides javax.swing.text.BoxView.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters
fx:float

the X coordinate >= 0.0f

fy:float

the Y coordinate >= 0.0f

a:Shape

the allocated region to render into

Returns:int

the location within the model that best represents the given point in the view

See Also
View#viewToModel