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

public Class BasicTextAreaUI

extends BasicTextUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.synth.SynthTextAreaUI, com.sun.java.swing.plaf.motif.MotifTextAreaUI
Imports
java.beans.*, java.awt.*, java.awt.event.KeyEvent, .InputEvent, javax.swing.*, javax.swing.event.DocumentEvent, javax.swing.text.*, javax.swing.plaf.*

Provides the look and feel for a plain text editor. In this implementation the default UI is extended to act as a simple view factory.

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
BasicTextAreaUI.PlainParagraph

Paragraph for representing plain-text lines that support bidirectional text.

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
BasicTextAreaUI()

Constructs a new BasicTextAreaUI object.

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.

pack-priv View
public static ComponentUI

Returns:

the UI
createUI
(JComponent
a text area
ta
)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a UI for a JTextArea.

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.

public Dimension

Returns:

the minimum size
getMinimumSize
(JComponent
the editor component
c
)

Overrides javax.swing.plaf.basic.BasicTextUI.getMinimumSize.

The method is overridden to take into account caret width.

public Dimension

Returns:

the preferred size
getPreferredSize
(JComponent
the editor component
c
)

Overrides javax.swing.plaf.basic.BasicTextUI.getPreferredSize.

The method is overridden to take into account caret width.

protected String

Returns:

the name ("TextArea")
getPropertyPrefix
()

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

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

protected void
installDefaults()

Overrides javax.swing.plaf.basic.BasicTextUI.installDefaults.

Initializes component properties, such as font, foreground, background, caret color, selection color, selected text color, disabled text color, border, and margin.

protected void
propertyChange(PropertyChangeEvent
the property change event
evt
)

Overrides javax.swing.plaf.basic.BasicTextUI.propertyChange.

This method gets called when a bound property is changed on the associated JTextComponent.

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

Constructor Detail

BasicTextAreaUIback to summary
public BasicTextAreaUI()

Constructs a new BasicTextAreaUI object.

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

createI18Nback to summary
pack-priv View createI18N(Element elem)
createUIback to summary
public static ComponentUI createUI(JComponent ta)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a UI for a JTextArea.

Parameters
ta:JComponent

a text area

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)
getMinimumSizeback to summary
public Dimension getMinimumSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicTextUI.getMinimumSize.

The method is overridden to take into account caret width.

Parameters
c:JComponent

the editor component

Returns:Dimension

the minimum size

Exceptions
IllegalArgumentException:
if invalid value is passed
Since
1.5
getPreferredSizeback to summary
public Dimension getPreferredSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicTextUI.getPreferredSize.

The method is overridden to take into account caret width.

Parameters
c:JComponent

the editor component

Returns:Dimension

the preferred size

Exceptions
IllegalArgumentException:
if invalid value is passed
Since
1.5
getPropertyPrefixback to summary
protected String getPropertyPrefix()

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

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

Returns:String

the name ("TextArea")

installDefaultsback to summary
protected void installDefaults()

Overrides javax.swing.plaf.basic.BasicTextUI.installDefaults.

Doc from javax.swing.plaf.basic.BasicTextUI.installDefaults.

Initializes component properties, such as font, foreground, background, caret color, selection color, selected text color, disabled text color, border, and margin. Each property is set if its current value is either null or a UIResource.

propertyChangeback to summary
protected void propertyChange(PropertyChangeEvent evt)

Overrides javax.swing.plaf.basic.BasicTextUI.propertyChange.

This method gets called when a bound property is changed on the associated JTextComponent. This is a hook which UI implementations may change to reflect how the UI displays bound properties of JTextComponent subclasses. This is implemented to rebuild the View when the WrapLine or the WrapStyleWord property changes.

Parameters
evt:PropertyChangeEvent

the property change event

javax.swing.plaf.basic back to summary

pack-priv Class BasicTextAreaUI.PlainParagraph

extends ParagraphView
Class Inheritance

Paragraph for representing plain-text lines that support bidirectional text.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
BasicTextAreaUI.PlainParagraph.LogicalView

This class can be used to represent a logical view for a flow.

Field Summary

Inherited from javax.swing.text.ParagraphView:
firstLineIndent

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected SizeRequirements
calculateMinorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.ParagraphView.calculateMinorAxisRequirements.

Calculate the needs for the paragraph along the minor axis.

public int
getFlowSpan(int index)

Overrides javax.swing.text.ParagraphView.getFlowSpan.

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

public void
setParent(View parent)

Overrides javax.swing.text.FlowView.setParent.

Sets the parent of the view.

protected void
setPropertiesFromAttributes()

Overrides javax.swing.text.ParagraphView.setPropertiesFromAttributes.

Set the cached properties from the attributes.

public void
setSize(float
the width >= 0
width
,
float
the height >= 0
height
)

Overrides javax.swing.text.BoxView.setSize.

Sets the size of the view.

Inherited from javax.swing.text.ParagraphView:
breakViewchangedUpdatecreateRowfindOffsetToCharactersInStringflipEastAndWestAtEndsgetAlignmentgetBreakWeightgetClosestPositionTogetFlowStartgetLayoutViewgetLayoutViewCountgetNextNorthSouthVisualPositionFromgetPartialSizegetTabBasegetTabSetnextTabStoppaintsetFirstLineIndentsetJustificationsetLineSpacing

Constructor Detail

PlainParagraphback to summary
pack-priv PlainParagraph(Element elem)

Method Detail

calculateMinorAxisRequirementsback to summary
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.ParagraphView.calculateMinorAxisRequirements.

Doc from javax.swing.text.ParagraphView.calculateMinorAxisRequirements.

Calculate the needs for the paragraph along the minor axis.

This uses size requirements of the superclass, modified to take into account the non-breakable areas at the adjacent views edges. The minimal size requirements for such views should be no less than the sum of all adjacent fragments.

If the axis parameter is neither View.X_AXIS nor View.Y_AXIS, IllegalArgumentException is thrown. If the r parameter is null, a new SizeRequirements object is created, otherwise the supplied SizeRequirements object is returned.

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.

setParentback to summary
public void setParent(View parent)

Overrides javax.swing.text.FlowView.setParent.

Doc from javax.swing.text.FlowView.setParent.

Sets the parent of the view. This is reimplemented to provide the superclass behavior as well as calling the loadChildren method if this view does not already have children. The children should not be loaded in the constructor because the act of setting the parent may cause them to try to search up the hierarchy (to get the hosting Container for example). If this view has children (the view is being moved from one place in the view hierarchy to another), the loadChildren method will not be called.

setPropertiesFromAttributesback to summary
protected void setPropertiesFromAttributes()

Overrides javax.swing.text.ParagraphView.setPropertiesFromAttributes.

Doc from javax.swing.text.ParagraphView.setPropertiesFromAttributes.

Set the cached properties from the attributes.

setSizeback to summary
public void setSize(float width, float height)

Overrides javax.swing.text.BoxView.setSize.

Sets the size of the view. If the size has changed, layout is redone. The size is the full size of the view including the inset areas.

Parameters
width:float

the width >= 0

height:float

the height >= 0

javax.swing.plaf.basic back to summary

pack-priv Class BasicTextAreaUI.PlainParagraph.LogicalView

extends CompositeView
Class Inheritance

This class can be used to represent a logical view for a flow. It keeps the children updated to reflect the state of the model, gives the logical child views access to the view hierarchy, and calculates a preferred span. It doesn't do any rendering, layout, or model/view translation.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
childAllocation(int index, Rectangle a)

Implements abstract javax.swing.text.CompositeView.childAllocation.

Returns the allocation for a given child.

protected void
forwardUpdateToView(View
the child view to forward the event to.
v
,
DocumentEvent
the change information from the associated document
e
,
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.View.forwardUpdateToView.

Forward the DocumentEvent to the given child view.

public float
getPreferredSpan(int axis)

Implements abstract javax.swing.text.View.getPreferredSpan.

Determines the preferred span for this view along an axis.

protected View
getViewAtPoint(int x, int y, Rectangle alloc)

Implements abstract javax.swing.text.CompositeView.getViewAtPoint.

Fetches the child view at the given coordinates.

protected int
getViewIndexAtPosition(int pos)

Overrides javax.swing.text.CompositeView.getViewIndexAtPosition.

Fetches the child view index representing the given position in the model.

protected boolean
isAfter(int x, int y, Rectangle alloc)

Implements abstract javax.swing.text.CompositeView.isAfter.

Tests whether a point lies after the rectangle range.

protected boolean
isBefore(int x, int y, Rectangle alloc)

Implements abstract javax.swing.text.CompositeView.isBefore.

Tests whether a point lies before the rectangle range.

protected void
loadChildren(ViewFactory f)

Overrides javax.swing.text.CompositeView.loadChildren.

Loads all of the children to initialize the view.

public void
paint(Graphics g, Shape allocation)

Implements abstract javax.swing.text.View.paint.

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

protected boolean
updateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory f)

Overrides javax.swing.text.View.updateChildren.

Updates the child views in response to receiving notification that the model changed, and there is change record for the element this view is responsible for.

Inherited from javax.swing.text.CompositeView:
flipEastAndWestAtEndsgetBottomInsetgetChildAllocationgetInsideAllocationgetLeftInsetgetNextEastWestVisualPositionFromgetNextNorthSouthVisualPositionFromgetNextVisualPositionFromgetRightInsetgetTopInsetgetViewgetViewAtPositiongetViewCountgetViewIndexmodelToViewmodelToViewreplacesetInsetssetParagraphInsetssetParentviewToModel

Constructor Detail

LogicalViewback to summary
pack-priv LogicalView(Element elem)

Method Detail

childAllocationback to summary
protected void childAllocation(int index, Rectangle a)

Implements abstract javax.swing.text.CompositeView.childAllocation.

Doc from javax.swing.text.CompositeView.childAllocation.

Returns the allocation for a given child.

forwardUpdateToViewback to summary
protected void forwardUpdateToView(View v, DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.forwardUpdateToView.

Forward the DocumentEvent to the given child view. This is implemented to reparent the child to the logical view (the children may have been parented by a row in the flow if they fit without breaking) and then execute the superclass behavior.

Parameters
v:View

the child view to forward the event to.

e: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

Since
1.3
See Also
forwardUpdate
getPreferredSpanback to summary
public float getPreferredSpan(int axis)

Implements abstract javax.swing.text.View.getPreferredSpan.

Doc from javax.swing.text.View.getPreferredSpan.

Determines the preferred span for this view along an axis.

getViewAtPointback to summary
protected View getViewAtPoint(int x, int y, Rectangle alloc)

Implements abstract javax.swing.text.CompositeView.getViewAtPoint.

Doc from javax.swing.text.CompositeView.getViewAtPoint.

Fetches the child view at the given coordinates.

getViewIndexAtPositionback to summary
protected int getViewIndexAtPosition(int pos)

Overrides javax.swing.text.CompositeView.getViewIndexAtPosition.

Doc from javax.swing.text.CompositeView.getViewIndexAtPosition.

Fetches the child view index representing the given position in the model. This is implemented to fetch the view in the case where there is a child view for each child element.

isAfterback to summary
protected boolean isAfter(int x, int y, Rectangle alloc)

Implements abstract javax.swing.text.CompositeView.isAfter.

Doc from javax.swing.text.CompositeView.isAfter.

Tests whether a point lies after the rectangle range.

isBeforeback to summary
protected boolean isBefore(int x, int y, Rectangle alloc)

Implements abstract javax.swing.text.CompositeView.isBefore.

Doc from javax.swing.text.CompositeView.isBefore.

Tests whether a point lies before the rectangle range.

loadChildrenback to summary
protected void loadChildren(ViewFactory f)

Overrides javax.swing.text.CompositeView.loadChildren.

Doc from javax.swing.text.CompositeView.loadChildren.

Loads all of the children to initialize the view. This is called by the setParent method. Subclasses can reimplement this to initialize their child views in a different manner. The default implementation creates a child view for each child element.

paintback to summary
public void paint(Graphics g, Shape allocation)

Implements abstract javax.swing.text.View.paint.

Doc from javax.swing.text.View.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.

updateChildrenback to summary
protected boolean updateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory f)

Overrides javax.swing.text.View.updateChildren.

Doc from javax.swing.text.View.updateChildren.

Updates the child views in response to receiving notification that the model changed, and there is change record for the element this view is responsible for. This is implemented to assume the child views are directly responsible for the child elements of the element this view represents. The ViewFactory is used to create child views for each element specified as added in the ElementChange, starting at the index specified in the given ElementChange. The number of child views representing the removed elements specified are removed.