Top Description Inners Fields Constructors Methods
javax.swing.text

public Class StyledEditorKit

extends DefaultEditorKit
Class Inheritance
Known Direct Subclasses
javax.swing.text.html.HTMLEditorKit, javax.swing.text.rtf.RTFEditorKit
Annotations
@SuppressWarnings:serial
Imports
java.io.*, java.awt.*, java.awt.event.ActionEvent, java.beans.PropertyChangeEvent, .PropertyChangeListener, javax.swing.event.*, javax.swing.Action, .JEditorPane, .KeyStroke, .UIManager

This is the set of things needed by a text component to be a reasonably functioning editor for some type of text document. This implementation provides a default implementation which treats text as styled text and provides a minimal set of actions for editing styled text.
Author
Timothy Prinzing

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
StyledEditorKit.AlignmentAction

An action to set paragraph alignment.

pack-priv class
StyledEditorKit.AttributeTracker

Tracks caret movement and keeps the input attributes set to reflect the current set of attribute definitions at the caret position.

public static class
StyledEditorKit.BoldAction

An action to toggle the bold attribute.

public static class
StyledEditorKit.FontFamilyAction

An action to set the font family in the associated JEditorPane.

public static class
StyledEditorKit.FontSizeAction

An action to set the font size in the associated JEditorPane.

public static class
StyledEditorKit.ForegroundAction

An action to set foreground color.

public static class
StyledEditorKit.ItalicAction

An action to toggle the italic attribute.

pack-priv static class
StyledEditorKit.StyledInsertBreakAction

StyledInsertBreakAction has similar behavior to that of DefaultEditorKit.InsertBreakAction.

public abstract static class
StyledEditorKit.StyledTextAction

An action that assumes it's being fired on a JEditorPane with a StyledEditorKit (or subclass) installed.

pack-priv static class
public static class
StyledEditorKit.UnderlineAction

An action to toggle the underline attribute.

Field Summary

Modifier and TypeField and Description
pack-priv Element
pack-priv Element
private static final Action[]
private static final ViewFactory
pack-priv MutableAttributeSet
inputAttributes

This is the set of attributes used to store the input attributes.

private StyledEditorKit.AttributeTracker
inputAttributeUpdater

This listener will be attached to the caret of the text component that the EditorKit gets installed into.

Inherited from javax.swing.text.DefaultEditorKit:
backwardActionbeepActionbeginActionbeginLineActionbeginLineUpActionbeginParagraphActionbeginWordActioncopyActioncutActiondefaultKeyTypedActiondeleteNextCharActiondeleteNextWordActiondeletePrevCharActiondeletePrevWordActiondownActionendActionendLineActionendLineDownActionEndOfLineStringPropertyendParagraphActionendWordActionforwardActioninsertBreakActioninsertContentActioninsertTabActionnextWordActionpageDownActionpageUpActionpasteActionpreviousWordActionreadOnlyActionselectAllActionselectionBackwardActionselectionBeginActionselectionBeginLineActionselectionBeginParagraphActionselectionBeginWordActionselectionDownActionselectionEndActionselectionEndLineActionselectionEndParagraphActionselectionEndWordActionselectionForwardActionselectionNextWordActionselectionPageDownActionselectionPageLeftActionselectionPageRightActionselectionPageUpActionselectionPreviousWordActionselectionUpActionselectLineActionselectParagraphActionselectWordActiontoggleComponentOrientationActionunselectActionupActionwritableAction

Constructor Summary

AccessConstructor and Description
public
StyledEditorKit()

Creates a new EditorKit used for styled documents.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the copy
clone
()

Overrides javax.swing.text.EditorKit.clone.

Creates a copy of the editor kit.
public Document

Returns:

the model
createDefaultDocument
()

Overrides javax.swing.text.DefaultEditorKit.createDefaultDocument.

Creates an uninitialized text storage model that is appropriate for this type of editor.
private void
createInputAttributes()

Creates the AttributeSet used for the selection.

protected void
createInputAttributes(Element
the element
element
,
MutableAttributeSet
the attributes
set
)

Copies the key/values in elements AttributeSet into set.

private void
createInputAttributeUpdated()

Creates a new AttributeTracker.

public void
deinstall(JEditorPane
the JEditorPane
c
)

Overrides javax.swing.text.EditorKit.deinstall.

Called when the kit is being removed from the JEditorPane.
public Action[]

Returns:

the command list
getActions
()

Overrides javax.swing.text.DefaultEditorKit.getActions.

Fetches the command list for the editor.
public Element

Returns:

the element
getCharacterAttributeRun
()

Fetches the element representing the current run of character attributes for the caret.

public MutableAttributeSet

Returns:

the attribute set
getInputAttributes
()

Overrides javax.swing.text.DefaultEditorKit.getInputAttributes.

Gets the input attributes for the pane.
public ViewFactory

Returns:

the factory
getViewFactory
()

Overrides javax.swing.text.DefaultEditorKit.getViewFactory.

Fetches a factory that is suitable for producing views of any models that are produced by this kit.
public void
install(JEditorPane
the JEditorPane
c
)

Overrides javax.swing.text.EditorKit.install.

Called when the kit is being installed into a JEditorPane.
Inherited from javax.swing.text.DefaultEditorKit:
createCaretgetContentTypereadreadwritewrite

Field Detail

currentParagraphback to summary
pack-priv Element currentParagraph
currentRunback to summary
pack-priv Element currentRun
defaultActionsback to summary
private static final Action[] defaultActions

Hides javax.swing.text.DefaultEditorKit.defaultActions.

defaultFactoryback to summary
private static final ViewFactory defaultFactory
inputAttributesback to summary
pack-priv MutableAttributeSet inputAttributes

This is the set of attributes used to store the input attributes.

inputAttributeUpdaterback to summary
private StyledEditorKit.AttributeTracker inputAttributeUpdater

This listener will be attached to the caret of the text component that the EditorKit gets installed into. This should keep the input attributes updated for use by the styled actions.

Constructor Detail

StyledEditorKitback to summary
public StyledEditorKit()

Creates a new EditorKit used for styled documents.

Method Detail

cloneback to summary
public Object clone()

Overrides javax.swing.text.EditorKit.clone.

Creates a copy of the editor kit.

Returns:Object

the copy

createDefaultDocumentback to summary
public Document createDefaultDocument()

Overrides javax.swing.text.DefaultEditorKit.createDefaultDocument.

Creates an uninitialized text storage model that is appropriate for this type of editor.

Returns:Document

the model

createInputAttributesback to summary
private void createInputAttributes()

Creates the AttributeSet used for the selection.

Annotations
@SuppressWarnings:serial
createInputAttributesback to summary
protected void createInputAttributes(Element element, MutableAttributeSet set)

Copies the key/values in elements AttributeSet into set. This does not copy component, icon, or element names attributes. Subclasses may wish to refine what is and what isn't copied here. But be sure to first remove all the attributes that are in set.

This is called anytime the caret moves over a different location.

Parameters
element:Element

the element

set:MutableAttributeSet

the attributes

createInputAttributeUpdatedback to summary
private void createInputAttributeUpdated()

Creates a new AttributeTracker.

deinstallback to summary
public void deinstall(JEditorPane c)

Overrides javax.swing.text.EditorKit.deinstall.

Called when the kit is being removed from the JEditorPane. This is used to unregister any listeners that were attached.

Parameters
c:JEditorPane

the JEditorPane

getActionsback to summary
public Action[] getActions()

Overrides javax.swing.text.DefaultEditorKit.getActions.

Fetches the command list for the editor. This is the list of commands supported by the superclass augmented by the collection of commands defined locally for style operations.

Returns:Action[]

the command list

getCharacterAttributeRunback to summary
public Element getCharacterAttributeRun()

Fetches the element representing the current run of character attributes for the caret.

Returns:Element

the element

getInputAttributesback to summary
public MutableAttributeSet getInputAttributes()

Overrides javax.swing.text.DefaultEditorKit.getInputAttributes.

Gets the input attributes for the pane. When the caret moves and there is no selection, the input attributes are automatically mutated to reflect the character attributes of the current caret location. The styled editing actions use the input attributes to carry out their actions.

Returns:MutableAttributeSet

the attribute set

getViewFactoryback to summary
public ViewFactory getViewFactory()

Overrides javax.swing.text.DefaultEditorKit.getViewFactory.

Fetches a factory that is suitable for producing views of any models that are produced by this kit. This is implemented to return View implementations for the following kinds of elements:

  • AbstractDocument.ContentElementName
  • AbstractDocument.ParagraphElementName
  • AbstractDocument.SectionElementName
  • StyleConstants.ComponentElementName
  • StyleConstants.IconElementName
Returns:ViewFactory

the factory

installback to summary
public void install(JEditorPane c)

Overrides javax.swing.text.EditorKit.install.

Called when the kit is being installed into a JEditorPane.

Parameters
c:JEditorPane

the JEditorPane

javax.swing.text back to summary

public Class StyledEditorKit.AlignmentAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to set paragraph alignment. This sets the StyleConstants.Alignment attribute for the currently selected range of the target JEditorPane. This is done by calling StyledDocument.setParagraphAttributes on the styled document associated with the target JEditorPane.

If the target text component is specified as the source of the ActionEvent and there is a command string, the command string will be interpreted as an integer that should be one of the legal values for the StyleConstants.Alignment attribute.

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.

Field Summary

Modifier and TypeField and Description
private int
a

Constructor Summary

AccessConstructor and Description
public
AlignmentAction(String
the action name
nm
,
int
the alignment >= 0
a
)

Creates a new AlignmentAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the action event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the alignment.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Field Detail

aback to summary
private int a

Constructor Detail

AlignmentActionback to summary
public AlignmentAction(String nm, int a)

Creates a new AlignmentAction.

Parameters
nm:String

the action name

a:int

the alignment >= 0

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the alignment.

Parameters
e:ActionEvent

the action event

javax.swing.text back to summary

pack-priv Class StyledEditorKit.AttributeTracker

extends Object
implements CaretListener, PropertyChangeListener, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.event.CaretListener
Annotations
@SuppressWarnings:serial

Tracks caret movement and keeps the input attributes set to reflect the current set of attribute definitions at the caret position.

This implements PropertyChangeListener to update the input attributes when the Document changes, as if the Document changes the attributes will almost certainly change.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
caretUpdate(CaretEvent
the caret event
e
)

Implements javax.swing.event.CaretListener.caretUpdate.

Called when the caret position is updated.
public void
propertyChange(PropertyChangeEvent
A PropertyChangeEvent object describing the event source and the property that has changed.
evt
)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.
pack-priv void
updateInputAttributes(int dot, int mark, JTextComponent c)

Updates the attributes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AttributeTrackerback to summary
pack-priv AttributeTracker()

Method Detail

caretUpdateback to summary
public void caretUpdate(CaretEvent e)

Implements javax.swing.event.CaretListener.caretUpdate.

Doc from javax.swing.event.CaretListener.caretUpdate.

Called when the caret position is updated.

Parameters
e:CaretEvent

the caret event

propertyChangeback to summary
public void propertyChange(PropertyChangeEvent evt)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Parameters
evt:PropertyChangeEvent

A PropertyChangeEvent object describing the event source and the property that has changed.

updateInputAttributesback to summary
pack-priv void updateInputAttributes(int dot, int mark, JTextComponent c)

Updates the attributes. dot and mark mark give the positions of the selection in c.

javax.swing.text back to summary

public Class StyledEditorKit.BoldAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to toggle the bold attribute.

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.

Constructor Summary

AccessConstructor and Description
public
BoldAction()

Constructs a new BoldAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the action event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Toggles the bold attribute.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Constructor Detail

BoldActionback to summary
public BoldAction()

Constructs a new BoldAction.

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Toggles the bold attribute.

Parameters
e:ActionEvent

the action event

javax.swing.text back to summary

public Class StyledEditorKit.FontFamilyAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to set the font family in the associated JEditorPane. This will use the family specified as the command string on the ActionEvent if there is one, otherwise the family that was initialized with will be used.

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.

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public
FontFamilyAction(String
the action name
nm
,
String
the font family
family
)

Creates a new FontFamilyAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the font family.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Field Detail

familyback to summary
private String family

Constructor Detail

FontFamilyActionback to summary
public FontFamilyAction(String nm, String family)

Creates a new FontFamilyAction.

Parameters
nm:String

the action name

family:String

the font family

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the font family.

Parameters
e:ActionEvent

the event

javax.swing.text back to summary

public Class StyledEditorKit.FontSizeAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to set the font size in the associated JEditorPane. This will use the size specified as the command string on the ActionEvent if there is one, otherwise the size that was initialized with will be used.

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.

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
public
FontSizeAction(String
the action name
nm
,
int
the font size
size
)

Creates a new FontSizeAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the action event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the font size.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Field Detail

sizeback to summary
private int size

Constructor Detail

FontSizeActionback to summary
public FontSizeAction(String nm, int size)

Creates a new FontSizeAction.

Parameters
nm:String

the action name

size:int

the font size

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the font size.

Parameters
e:ActionEvent

the action event

javax.swing.text back to summary

public Class StyledEditorKit.ForegroundAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to set foreground color. This sets the StyleConstants.Foreground attribute for the currently selected range of the target JEditorPane. This is done by calling StyledDocument.setCharacterAttributes on the styled document associated with the target JEditorPane.

If the target text component is specified as the source of the ActionEvent and there is a command string, the command string will be interpreted as the foreground color. It will be interpreted by called Color.decode, and should therefore be legal input for that method.

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.

Field Summary

Modifier and TypeField and Description
private Color

Constructor Summary

AccessConstructor and Description
public
ForegroundAction(String
the action name
nm
,
Color
the foreground color
fg
)

Creates a new ForegroundAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the action event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the foreground color.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Field Detail

fgback to summary
private Color fg

Constructor Detail

ForegroundActionback to summary
public ForegroundAction(String nm, Color fg)

Creates a new ForegroundAction.

Parameters
nm:String

the action name

fg:Color

the foreground color

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Sets the foreground color.

Parameters
e:ActionEvent

the action event

javax.swing.text back to summary

public Class StyledEditorKit.ItalicAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to toggle the italic attribute.

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.

Constructor Summary

AccessConstructor and Description
public
ItalicAction()

Constructs a new ItalicAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the action event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Toggles the italic attribute.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Constructor Detail

ItalicActionback to summary
public ItalicAction()

Constructs a new ItalicAction.

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Toggles the italic attribute.

Parameters
e:ActionEvent

the action event

javax.swing.text back to summary

pack-priv Class StyledEditorKit.StyledInsertBreakAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

StyledInsertBreakAction has similar behavior to that of DefaultEditorKit.InsertBreakAction. That is when its actionPerformed method is invoked, a newline is inserted. Beyond that, this will reset the input attributes to what they were before the newline was inserted.

Field Summary

Modifier and TypeField and Description
private SimpleAttributeSet

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the event to be processed
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Invoked when an action occurs.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Field Detail

tempSetback to summary
private SimpleAttributeSet tempSet

Constructor Detail

StyledInsertBreakActionback to summary
pack-priv StyledInsertBreakAction()

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Doc from java.awt.event.ActionListener.actionPerformed.

Invoked when an action occurs.

Parameters
e:ActionEvent

the event to be processed

javax.swing.text back to summary

public abstract Class StyledEditorKit.StyledTextAction

extends TextAction
Class Inheritance
Known Direct Subclasses
javax.swing.text.StyledEditorKit.FontFamilyAction, javax.swing.text.StyledEditorKit.FontSizeAction, javax.swing.text.StyledEditorKit.ForegroundAction, javax.swing.text.StyledEditorKit.AlignmentAction, javax.swing.text.StyledEditorKit.BoldAction, javax.swing.text.StyledEditorKit.ItalicAction, javax.swing.text.StyledEditorKit.UnderlineAction, javax.swing.text.StyledEditorKit.StyledInsertBreakAction, javax.swing.text.html.HTMLEditorKit.HTMLTextAction
Annotations
@SuppressWarnings:serial

An action that assumes it's being fired on a JEditorPane with a StyledEditorKit (or subclass) installed. This has some convenience methods for causing character or paragraph level attribute changes. The convenience methods will throw an IllegalArgumentException if the assumption of a StyledDocument, a JEditorPane, or a StyledEditorKit fail to be true.

The component that gets acted upon by the action will be the source of the ActionEvent if the source can be narrowed to a JEditorPane type. If the source can't be narrowed, the most recently focused text component is changed. If neither of these are the case, the action cannot be performed.

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.

Constructor Summary

AccessConstructor and Description
public
StyledTextAction(String
the name of the action
nm
)

Creates a new StyledTextAction from a string action name.

Method Summary

Modifier and TypeMethod and Description
protected final JEditorPane

Returns:

the editor
getEditor
(ActionEvent
the action event
e
)

Gets the target editor for an action.

protected final StyledDocument

Returns:

the document
getStyledDocument
(JEditorPane
the editor
e
)

Gets the document associated with an editor pane.

protected final StyledEditorKit

Returns:

the kit
getStyledEditorKit
(JEditorPane
the editor pane
e
)

Gets the editor kit associated with an editor pane.

protected final void
setCharacterAttributes(JEditorPane
the editor
editor
,
AttributeSet
the attributes
attr
,
boolean
if true, then replace the existing attributes first
replace
)

Applies the given attributes to character content.

protected final void
setParagraphAttributes(JEditorPane
the editor
editor
,
AttributeSet
the attributes
attr
,
boolean
if true, replace the existing attributes first
replace
)

Applies the given attributes to paragraphs.

Inherited from javax.swing.text.TextAction:
augmentListgetFocusedComponentgetTextComponent

Constructor Detail

StyledTextActionback to summary
public StyledTextAction(String nm)

Creates a new StyledTextAction from a string action name.

Parameters
nm:String

the name of the action

Method Detail

getEditorback to summary
protected final JEditorPane getEditor(ActionEvent e)

Gets the target editor for an action.

Parameters
e:ActionEvent

the action event

Returns:JEditorPane

the editor

getStyledDocumentback to summary
protected final StyledDocument getStyledDocument(JEditorPane e)

Gets the document associated with an editor pane.

Parameters
e:JEditorPane

the editor

Returns:StyledDocument

the document

Exceptions
IllegalArgumentException:
for the wrong document type
getStyledEditorKitback to summary
protected final StyledEditorKit getStyledEditorKit(JEditorPane e)

Gets the editor kit associated with an editor pane.

Parameters
e:JEditorPane

the editor pane

Returns:StyledEditorKit

the kit

Exceptions
IllegalArgumentException:
for the wrong document type
setCharacterAttributesback to summary
protected final void setCharacterAttributes(JEditorPane editor, AttributeSet attr, boolean replace)

Applies the given attributes to character content. If there is a selection, the attributes are applied to the selection range. If there is no selection, the attributes are applied to the input attribute set which defines the attributes for any new text that gets inserted.

Parameters
editor:JEditorPane

the editor

attr:AttributeSet

the attributes

replace:boolean

if true, then replace the existing attributes first

setParagraphAttributesback to summary
protected final void setParagraphAttributes(JEditorPane editor, AttributeSet attr, boolean replace)

Applies the given attributes to paragraphs. If there is a selection, the attributes are applied to the paragraphs that intersect the selection. if there is no selection, the attributes are applied to the paragraph at the current caret position.

Parameters
editor:JEditorPane

the editor

attr:AttributeSet

the attributes

replace:boolean

if true, replace the existing attributes first

javax.swing.text back to summary

pack-priv Class StyledEditorKit.StyledViewFactory

extends Object
implements ViewFactory
Class Inheritance
All Implemented Interfaces
javax.swing.text.ViewFactory

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public View
create(Element
the piece of the document to build a view of
elem
)

Implements javax.swing.text.ViewFactory.create.

Creates a view from the given structural element of a document.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StyledViewFactoryback to summary
pack-priv StyledViewFactory()

Method Detail

createback to summary
public View create(Element elem)

Implements javax.swing.text.ViewFactory.create.

Doc from javax.swing.text.ViewFactory.create.

Creates a view from the given structural element of a document.

Parameters
elem:Element

the piece of the document to build a view of

Returns:View

the view

javax.swing.text back to summary

public Class StyledEditorKit.UnderlineAction

extends StyledTextAction
Class Inheritance
Annotations
@SuppressWarnings:serial

An action to toggle the underline attribute.

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.

Constructor Summary

AccessConstructor and Description
public
UnderlineAction()

Constructs a new UnderlineAction.

Method Summary

Modifier and TypeMethod and Description
public void
actionPerformed(ActionEvent
the action event
e
)

Implements java.awt.event.ActionListener.actionPerformed.

Toggles the Underline attribute.
Inherited from javax.swing.text.StyledEditorKit.StyledTextAction:
getEditorgetStyledDocumentgetStyledEditorKitsetCharacterAttributessetParagraphAttributes

Constructor Detail

UnderlineActionback to summary
public UnderlineAction()

Constructs a new UnderlineAction.

Method Detail

actionPerformedback to summary
public void actionPerformed(ActionEvent e)

Implements java.awt.event.ActionListener.actionPerformed.

Toggles the Underline attribute.

Parameters
e:ActionEvent

the action event