javax.swing.text

Class StyledEditorKit

Implemented Interfaces:
Cloneable, Serializable
Known Direct Subclasses:
HTMLEditorKit, RTFEditorKit

public class StyledEditorKit
extends DefaultEditorKit

An EditorKit that supports editing styled text.
See Also:
Serialized Form

Nested Class Summary

static class
StyledEditorKit.AlignmentAction
Sets the alignment attribute on the selected text.
static class
StyledEditorKit.BoldAction
Toggles the bold attribute for the selected text.
static class
StyledEditorKit.FontFamilyAction
Sets the font family attribute on the selected text.
static class
StyledEditorKit.FontSizeAction
Sets the font size attribute on the selected text.
static class
StyledEditorKit.ForegroundAction
Sets the foreground color attribute on the selected text.
static class
StyledEditorKit.ItalicAction
Toggles the italic attribute for the selected text.
static class
StyledEditorKit.StyledTextAction
The abstract superclass of all styled TextActions.
static class
StyledEditorKit.UnderlineAction
Toggles the underline attribute for the selected text.

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

Fields inherited from class javax.swing.text.DefaultEditorKit

EndOfLineStringProperty, backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deletePrevCharAction, downAction, endAction, endLineAction, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectLineAction, selectParagraphAction, selectWordAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, upAction, writableAction

Constructor Summary

StyledEditorKit()
Creates a new instance of StyledEditorKit.

Method Summary

Object
clone()
Creates an exact copy of this StyledEditorKit.
Document
createDefaultDocument()
Creates the default Document supported by this EditorKit.
protected void
createInputAttributes(Element element, MutableAttributeSet set)
Copies the text attributes from element to set.
void
deinstall(JEditorPane component)
Deinstalls this EditorKit from the specified JEditorPane.
Action[]
getActions()
Returns the Actions supported by this EditorKit.
Element
getCharacterAttributeRun()
Returns the Element that represents the character run at the current caret position.
MutableAttributeSet
getInputAttributes()
Returns the current input attributes.
ViewFactory
getViewFactory()
Returns a ViewFactory that is able to create Views for Elements that are supported by this EditorKit, namely the following types of Elements:
void
install(JEditorPane component)
Installs this EditorKit on the specified JEditorPane.

Methods inherited from class javax.swing.text.DefaultEditorKit

createCaret, createDefaultDocument, getActions, getContentType, getViewFactory, read, read, write, write

Methods inherited from class javax.swing.text.EditorKit

clone, createCaret, createDefaultDocument, deinstall, getActions, getContentType, getViewFactory, install, read, read, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

StyledEditorKit

public StyledEditorKit()
Creates a new instance of StyledEditorKit.

Method Details

clone

public Object clone()
Creates an exact copy of this StyledEditorKit.
Overrides:
clone in interface EditorKit
Returns:
an exact copy of this StyledEditorKit

createDefaultDocument

public Document createDefaultDocument()
Creates the default Document supported by this EditorKit. This is an instance of DefaultStyledDocument in this case but may be overridden by subclasses.
Overrides:
createDefaultDocument in interface DefaultEditorKit
Returns:
an instance of DefaultStyledDocument

createInputAttributes

protected void createInputAttributes(Element element,
                                     MutableAttributeSet set)
Copies the text attributes from element to set. This is called everytime when the caret position changes to keep track of the current input attributes. The attributes in set are cleaned before adding the attributes of element. This method filters out attributes for element names, Icons and Components.
Parameters:
element - the Element from which to copy the text attributes
set - the inputAttributes to copy the attributes to

deinstall

public void deinstall(JEditorPane component)
Deinstalls this EditorKit from the specified JEditorPane. This basically involves removing all listeners from JEditorPane that have been set up by this EditorKit.
Overrides:
deinstall in interface EditorKit
Parameters:
component - the JEditorPane from which to deinstall this EditorKit

getActions

public Action[] getActions()
Returns the Actions supported by this EditorKit. This includes the StyledEditorKit.BoldAction, StyledEditorKit.ItalicAction and StyledEditorKit.UnderlineAction as well as the Actions supported by DefaultEditorKit. The other Actions of StyledEditorKit are not returned here, since they require a parameter and thus custom instantiation.
Overrides:
getActions in interface DefaultEditorKit
Returns:
the Actions supported by this EditorKit

getCharacterAttributeRun

public Element getCharacterAttributeRun()
Returns the Element that represents the character run at the current caret position.
Returns:
the Element that represents the character run at the current caret position

getInputAttributes

public MutableAttributeSet getInputAttributes()
Returns the current input attributes. These are automatically set on any newly inserted content, if not specified otherwise.
Returns:
the current input attributes

getViewFactory

public ViewFactory getViewFactory()
Overrides:
getViewFactory in interface DefaultEditorKit
Returns:
a ViewFactory that is able to create Views for Elements that are supported by this EditorKit

install

public void install(JEditorPane component)
Installs this EditorKit on the specified JEditorPane. This basically involves setting up required listeners on the JEditorPane.
Overrides:
install in interface EditorKit
Parameters:
component - the JEditorPane to install this EditorKit on

StyledEditorKit.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.