StyledEditorKit (Java 2 Platform SE 5.0) (original) (raw)
javax.swing.text
Class StyledEditorKit
java.lang.Object
javax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
javax.swing.text.StyledEditorKit
All Implemented Interfaces:
Direct Known Subclasses:
public class StyledEditorKit
extends DefaultEditorKit
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.
Nested Class Summary | |
---|---|
static class | StyledEditorKit.AlignmentAction An action to set paragraph alignment. |
static class | StyledEditorKit.BoldAction An action to toggle the bold attribute. |
static class | StyledEditorKit.FontFamilyAction An action to set the font family in the associated JEditorPane. |
static class | StyledEditorKit.FontSizeAction An action to set the font size in the associated JEditorPane. |
static class | StyledEditorKit.ForegroundAction An action to set foreground color. |
static class | StyledEditorKit.ItalicAction An action to toggle the italic attribute. |
static class | StyledEditorKit.StyledTextAction An action that assumes it's being fired on a JEditorPane with a StyledEditorKit (or subclass) installed. |
static class | StyledEditorKit.UnderlineAction An action to toggle the underline attribute. |
Nested classes/interfaces inherited from class javax.swing.text.DefaultEditorKit |
---|
DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction |
Field Summary |
---|
Constructor Summary |
---|
StyledEditorKit() Creates a new EditorKit used for styled documents. |
Method Summary | |
---|---|
Object | clone() Creates a copy of the editor kit. |
Document | createDefaultDocument() Creates an uninitialized text storage model that is appropriate for this type of editor. |
protected void | [createInputAttributes](../../../javax/swing/text/StyledEditorKit.html#createInputAttributes%28javax.swing.text.Element, javax.swing.text.MutableAttributeSet%29)(Element element,MutableAttributeSet set) Copies the key/values in elements AttributeSet intoset. |
void | deinstall(JEditorPane c) Called when the kit is being removed from the JEditorPane. |
Action[] | getActions() Fetches the command list for the editor. |
Element | getCharacterAttributeRun() Fetches the element representing the current run of character attributes for the caret. |
MutableAttributeSet | getInputAttributes() Gets the input attributes for the pane. |
ViewFactory | getViewFactory() Fetches a factory that is suitable for producing views of any models that are produced by this kit. |
void | install(JEditorPane c) Called when the kit is being installed into a JEditorPane. |
Methods inherited from class javax.swing.text.DefaultEditorKit |
---|
createCaret, getContentType, [read](../../../javax/swing/text/DefaultEditorKit.html#read%28java.io.InputStream, javax.swing.text.Document, int%29), [read](../../../javax/swing/text/DefaultEditorKit.html#read%28java.io.Reader, javax.swing.text.Document, int%29), [write](../../../javax/swing/text/DefaultEditorKit.html#write%28java.io.OutputStream, javax.swing.text.Document, int, int%29), [write](../../../javax/swing/text/DefaultEditorKit.html#write%28java.io.Writer, javax.swing.text.Document, int, int%29) |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29) |
Constructor Detail |
---|
StyledEditorKit
public StyledEditorKit()
Creates a new EditorKit used for styled documents.
Method Detail |
---|
getInputAttributes
public MutableAttributeSet 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:
the attribute set
getCharacterAttributeRun
public Element getCharacterAttributeRun()
Fetches the element representing the current run of character attributes for the caret.
Returns:
the element
getActions
public Action[] 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.
Overrides:
[getActions](../../../javax/swing/text/DefaultEditorKit.html#getActions%28%29)
in class [DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text")
Returns:
the command list
createDefaultDocument
public Document createDefaultDocument()
Creates an uninitialized text storage model that is appropriate for this type of editor.
Overrides:
[createDefaultDocument](../../../javax/swing/text/DefaultEditorKit.html#createDefaultDocument%28%29)
in class [DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text")
Returns:
the model
install
public void install(JEditorPane c)
Called when the kit is being installed into a JEditorPane.
Overrides:
[install](../../../javax/swing/text/EditorKit.html#install%28javax.swing.JEditorPane%29)
in class [EditorKit](../../../javax/swing/text/EditorKit.html "class in javax.swing.text")
Parameters:
c
- the JEditorPane
deinstall
public void deinstall(JEditorPane c)
Called when the kit is being removed from the JEditorPane. This is used to unregister any listeners that were attached.
Overrides:
[deinstall](../../../javax/swing/text/EditorKit.html#deinstall%28javax.swing.JEditorPane%29)
in class [EditorKit](../../../javax/swing/text/EditorKit.html "class in javax.swing.text")
Parameters:
c
- the JEditorPane
getViewFactory
public ViewFactory 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
Overrides:
[getViewFactory](../../../javax/swing/text/DefaultEditorKit.html#getViewFactory%28%29)
in class [DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text")
Returns:
the factory
clone
public Object clone()
Creates a copy of the editor kit.
Overrides:
[clone](../../../javax/swing/text/EditorKit.html#clone%28%29)
in class [EditorKit](../../../javax/swing/text/EditorKit.html "class in javax.swing.text")
Returns:
the copy
See Also:
createInputAttributes
protected void createInputAttributes(Element element, MutableAttributeSet set)
Copies the key/values in element
s AttributeSet intoset
. 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.
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.