Home » openjdk-7 » javax » swing » text » [javadoc | source]
javax.swing.text
public class: StyledEditorKit [javadoc | source]
java.lang.Object
   javax.swing.text.EditorKit
      javax.swing.text.DefaultEditorKit
         javax.swing.text.StyledEditorKit

All Implemented Interfaces:
    Cloneable, Serializable

Direct Known Subclasses:
    MyHTMLEditorKit, RTFEditorKit, BasicEditorKit, HTMLEditorKit

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:
class  StyledEditorKit.AttributeTracker  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. 

static class  StyledEditorKit.StyledViewFactory   
abstract public static class  StyledEditorKit.StyledTextAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.FontFamilyAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.FontSizeAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.ForegroundAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.AlignmentAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.BoldAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.ItalicAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

public static class  StyledEditorKit.UnderlineAction  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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}. 

static class  StyledEditorKit.StyledInsertBreakAction  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
 Element currentRun     
 Element currentParagraph     
 MutableAttributeSet inputAttributes    This is the set of attributes used to store the input attributes. 
Fields inherited from javax.swing.text.DefaultEditorKit:
EndOfLineStringProperty,  insertContentAction,  insertBreakAction,  insertTabAction,  deletePrevCharAction,  deleteNextCharAction,  deleteNextWordAction,  deletePrevWordAction,  readOnlyAction,  writableAction,  cutAction,  copyAction,  pasteAction,  beepAction,  pageUpAction,  pageDownAction,  selectionPageUpAction,  selectionPageDownAction,  selectionPageLeftAction,  selectionPageRightAction,  forwardAction,  backwardAction,  selectionForwardAction,  selectionBackwardAction,  upAction,  downAction,  selectionUpAction,  selectionDownAction,  beginWordAction,  endWordAction,  selectionBeginWordAction,  selectionEndWordAction,  previousWordAction,  nextWordAction,  selectionPreviousWordAction,  selectionNextWordAction,  beginLineAction,  endLineAction,  selectionBeginLineAction,  selectionEndLineAction,  beginParagraphAction,  endParagraphAction,  selectionBeginParagraphAction,  selectionEndParagraphAction,  beginAction,  endAction,  selectionBeginAction,  selectionEndAction,  selectWordAction,  selectLineAction,  selectParagraphAction,  selectAllAction,  unselectAction,  toggleComponentOrientationAction,  defaultKeyTypedAction
Constructor:
 public StyledEditorKit() 
Method from javax.swing.text.StyledEditorKit Summary:
clone,   createDefaultDocument,   createInputAttributes,   deinstall,   getActions,   getCharacterAttributeRun,   getInputAttributes,   getViewFactory,   install
Methods from javax.swing.text.DefaultEditorKit:
createCaret,   createDefaultDocument,   getActions,   getContentType,   getInputAttributes,   getViewFactory,   read,   read,   write,   write
Methods from javax.swing.text.EditorKit:
clone,   createCaret,   createDefaultDocument,   deinstall,   getActions,   getContentType,   getViewFactory,   install,   read,   read,   write,   write
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.StyledEditorKit Detail:
 public Object clone() 
    Creates a copy of the editor kit.
 public 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 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.

 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.
 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.
 public Element getCharacterAttributeRun() 
    Fetches the element representing the current run of character attributes for the caret.
 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.
 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
 public  void install(JEditorPane c) 
    Called when the kit is being installed into a JEditorPane.