StyledEditorKit (Java Platform SE 8 ) (original) (raw)
- javax.swing.text.EditorKit
- javax.swing.text.DefaultEditorKit
- javax.swing.text.StyledEditorKit
- javax.swing.text.DefaultEditorKit
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
HTMLEditorKit, RTFEditorKit
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
Nested Classes
Modifier and Type Class Description 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](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text") `[DefaultEditorKit.BeepAction](../../../javax/swing/text/DefaultEditorKit.BeepAction.html "class in javax.swing.text"), [DefaultEditorKit.CopyAction](../../../javax/swing/text/DefaultEditorKit.CopyAction.html "class in javax.swing.text"), [DefaultEditorKit.CutAction](../../../javax/swing/text/DefaultEditorKit.CutAction.html "class in javax.swing.text"), [DefaultEditorKit.DefaultKeyTypedAction](../../../javax/swing/text/DefaultEditorKit.DefaultKeyTypedAction.html "class in javax.swing.text"), [DefaultEditorKit.InsertBreakAction](../../../javax/swing/text/DefaultEditorKit.InsertBreakAction.html "class in javax.swing.text"), [DefaultEditorKit.InsertContentAction](../../../javax/swing/text/DefaultEditorKit.InsertContentAction.html "class in javax.swing.text"), [DefaultEditorKit.InsertTabAction](../../../javax/swing/text/DefaultEditorKit.InsertTabAction.html "class in javax.swing.text"), [DefaultEditorKit.PasteAction](../../../javax/swing/text/DefaultEditorKit.PasteAction.html "class in javax.swing.text")`
Field Summary
* ### Fields inherited from class javax.swing.text.[DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text") `[backwardAction](../../../javax/swing/text/DefaultEditorKit.html#backwardAction), [beepAction](../../../javax/swing/text/DefaultEditorKit.html#beepAction), [beginAction](../../../javax/swing/text/DefaultEditorKit.html#beginAction), [beginLineAction](../../../javax/swing/text/DefaultEditorKit.html#beginLineAction), [beginParagraphAction](../../../javax/swing/text/DefaultEditorKit.html#beginParagraphAction), [beginWordAction](../../../javax/swing/text/DefaultEditorKit.html#beginWordAction), [copyAction](../../../javax/swing/text/DefaultEditorKit.html#copyAction), [cutAction](../../../javax/swing/text/DefaultEditorKit.html#cutAction), [defaultKeyTypedAction](../../../javax/swing/text/DefaultEditorKit.html#defaultKeyTypedAction), [deleteNextCharAction](../../../javax/swing/text/DefaultEditorKit.html#deleteNextCharAction), [deleteNextWordAction](../../../javax/swing/text/DefaultEditorKit.html#deleteNextWordAction), [deletePrevCharAction](../../../javax/swing/text/DefaultEditorKit.html#deletePrevCharAction), [deletePrevWordAction](../../../javax/swing/text/DefaultEditorKit.html#deletePrevWordAction), [downAction](../../../javax/swing/text/DefaultEditorKit.html#downAction), [endAction](../../../javax/swing/text/DefaultEditorKit.html#endAction), [endLineAction](../../../javax/swing/text/DefaultEditorKit.html#endLineAction), [EndOfLineStringProperty](../../../javax/swing/text/DefaultEditorKit.html#EndOfLineStringProperty), [endParagraphAction](../../../javax/swing/text/DefaultEditorKit.html#endParagraphAction), [endWordAction](../../../javax/swing/text/DefaultEditorKit.html#endWordAction), [forwardAction](../../../javax/swing/text/DefaultEditorKit.html#forwardAction), [insertBreakAction](../../../javax/swing/text/DefaultEditorKit.html#insertBreakAction), [insertContentAction](../../../javax/swing/text/DefaultEditorKit.html#insertContentAction), [insertTabAction](../../../javax/swing/text/DefaultEditorKit.html#insertTabAction), [nextWordAction](../../../javax/swing/text/DefaultEditorKit.html#nextWordAction), [pageDownAction](../../../javax/swing/text/DefaultEditorKit.html#pageDownAction), [pageUpAction](../../../javax/swing/text/DefaultEditorKit.html#pageUpAction), [pasteAction](../../../javax/swing/text/DefaultEditorKit.html#pasteAction), [previousWordAction](../../../javax/swing/text/DefaultEditorKit.html#previousWordAction), [readOnlyAction](../../../javax/swing/text/DefaultEditorKit.html#readOnlyAction), [selectAllAction](../../../javax/swing/text/DefaultEditorKit.html#selectAllAction), [selectionBackwardAction](../../../javax/swing/text/DefaultEditorKit.html#selectionBackwardAction), [selectionBeginAction](../../../javax/swing/text/DefaultEditorKit.html#selectionBeginAction), [selectionBeginLineAction](../../../javax/swing/text/DefaultEditorKit.html#selectionBeginLineAction), [selectionBeginParagraphAction](../../../javax/swing/text/DefaultEditorKit.html#selectionBeginParagraphAction), [selectionBeginWordAction](../../../javax/swing/text/DefaultEditorKit.html#selectionBeginWordAction), [selectionDownAction](../../../javax/swing/text/DefaultEditorKit.html#selectionDownAction), [selectionEndAction](../../../javax/swing/text/DefaultEditorKit.html#selectionEndAction), [selectionEndLineAction](../../../javax/swing/text/DefaultEditorKit.html#selectionEndLineAction), [selectionEndParagraphAction](../../../javax/swing/text/DefaultEditorKit.html#selectionEndParagraphAction), [selectionEndWordAction](../../../javax/swing/text/DefaultEditorKit.html#selectionEndWordAction), [selectionForwardAction](../../../javax/swing/text/DefaultEditorKit.html#selectionForwardAction), [selectionNextWordAction](../../../javax/swing/text/DefaultEditorKit.html#selectionNextWordAction), [selectionPreviousWordAction](../../../javax/swing/text/DefaultEditorKit.html#selectionPreviousWordAction), [selectionUpAction](../../../javax/swing/text/DefaultEditorKit.html#selectionUpAction), [selectLineAction](../../../javax/swing/text/DefaultEditorKit.html#selectLineAction), [selectParagraphAction](../../../javax/swing/text/DefaultEditorKit.html#selectParagraphAction), [selectWordAction](../../../javax/swing/text/DefaultEditorKit.html#selectWordAction), [upAction](../../../javax/swing/text/DefaultEditorKit.html#upAction), [writableAction](../../../javax/swing/text/DefaultEditorKit.html#writableAction)`
Constructor Summary
Constructors
Constructor Description StyledEditorKit() Creates a new EditorKit used for styled documents. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description 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(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](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text") `[createCaret](../../../javax/swing/text/DefaultEditorKit.html#createCaret--), [getContentType](../../../javax/swing/text/DefaultEditorKit.html#getContentType--), [read](../../../javax/swing/text/DefaultEditorKit.html#read-java.io.InputStream-javax.swing.text.Document-int-), [read](../../../javax/swing/text/DefaultEditorKit.html#read-java.io.Reader-javax.swing.text.Document-int-), [write](../../../javax/swing/text/DefaultEditorKit.html#write-java.io.OutputStream-javax.swing.text.Document-int-int-), [write](../../../javax/swing/text/DefaultEditorKit.html#write-java.io.Writer-javax.swing.text.Document-int-int-)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[equals](../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../java/lang/Object.html#finalize--), [getClass](../../../java/lang/Object.html#getClass--), [hashCode](../../../java/lang/Object.html#hashCode--), [notify](../../../java/lang/Object.html#notify--), [notifyAll](../../../java/lang/Object.html#notifyAll--), [toString](../../../java/lang/Object.html#toString--), [wait](../../../java/lang/Object.html#wait--), [wait](../../../java/lang/Object.html#wait-long-), [wait](../../../java/lang/Object.html#wait-long-int-)`
Constructor Detail
* #### StyledEditorKit public StyledEditorKit() Creates a new EditorKit used for styled documents.
Method Detail
* #### getInputAttributes public [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text") 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](../../../javax/swing/text/Element.html "interface in javax.swing.text") getCharacterAttributeRun() Fetches the element representing the current run of character attributes for the caret. Returns: the element * #### getActions public [Action](../../../javax/swing/Action.html "interface in javax.swing")[] 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--)` in class `[DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text")` Returns: the command list * #### createDefaultDocument public [Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") createDefaultDocument() Creates an uninitialized text storage model that is appropriate for this type of editor. Overrides: `[createDefaultDocument](../../../javax/swing/text/DefaultEditorKit.html#createDefaultDocument--)` in class `[DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text")` Returns: the model * #### install public void install([JEditorPane](../../../javax/swing/JEditorPane.html "class in javax.swing") c) Called when the kit is being installed into a JEditorPane. Overrides: `[install](../../../javax/swing/text/EditorKit.html#install-javax.swing.JEditorPane-)` in class `[EditorKit](../../../javax/swing/text/EditorKit.html "class in javax.swing.text")` Parameters: `c` \- the JEditorPane * #### deinstall public void deinstall([JEditorPane](../../../javax/swing/JEditorPane.html "class in javax.swing") 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-javax.swing.JEditorPane-)` in class `[EditorKit](../../../javax/swing/text/EditorKit.html "class in javax.swing.text")` Parameters: `c` \- the JEditorPane * #### getViewFactory public [ViewFactory](../../../javax/swing/text/ViewFactory.html "interface in javax.swing.text") 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--)` in class `[DefaultEditorKit](../../../javax/swing/text/DefaultEditorKit.html "class in javax.swing.text")` Returns: the factory * #### clone public [Object](../../../java/lang/Object.html "class in java.lang") clone() Creates a copy of the editor kit. Overrides: `[clone](../../../javax/swing/text/EditorKit.html#clone--)` in class `[EditorKit](../../../javax/swing/text/EditorKit.html "class in javax.swing.text")` Returns: the copy See Also: [Cloneable](../../../java/lang/Cloneable.html "interface in java.lang") * #### createInputAttributes protected void createInputAttributes([Element](../../../javax/swing/text/Element.html "interface in javax.swing.text") element, [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text") set) Copies the key/values in `element`s 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.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.