javax.swing.text
Class StyledEditorKit.StyledTextAction

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction 
      extended by javax.swing.text.TextAction sample code for javax.swing.text.TextAction definition code for javax.swing.text.TextAction 
          extended by javax.swing.text.StyledEditorKit.StyledTextAction
All Implemented Interfaces:
ActionListener sample code for java.awt.event.ActionListener definition code for java.awt.event.ActionListener , Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , EventListener sample code for java.util.EventListener definition code for java.util.EventListener , Action sample code for javax.swing.Action definition code for javax.swing.Action
Direct Known Subclasses:
HTMLEditorKit.HTMLTextAction sample code for javax.swing.text.html.HTMLEditorKit.HTMLTextAction definition code for javax.swing.text.html.HTMLEditorKit.HTMLTextAction , StyledEditorKit.AlignmentAction sample code for javax.swing.text.StyledEditorKit.AlignmentAction definition code for javax.swing.text.StyledEditorKit.AlignmentAction , StyledEditorKit.BoldAction sample code for javax.swing.text.StyledEditorKit.BoldAction definition code for javax.swing.text.StyledEditorKit.BoldAction , StyledEditorKit.FontFamilyAction sample code for javax.swing.text.StyledEditorKit.FontFamilyAction definition code for javax.swing.text.StyledEditorKit.FontFamilyAction , StyledEditorKit.FontSizeAction sample code for javax.swing.text.StyledEditorKit.FontSizeAction definition code for javax.swing.text.StyledEditorKit.FontSizeAction , StyledEditorKit.ForegroundAction sample code for javax.swing.text.StyledEditorKit.ForegroundAction definition code for javax.swing.text.StyledEditorKit.ForegroundAction , StyledEditorKit.ItalicAction sample code for javax.swing.text.StyledEditorKit.ItalicAction definition code for javax.swing.text.StyledEditorKit.ItalicAction , StyledEditorKit.UnderlineAction sample code for javax.swing.text.StyledEditorKit.UnderlineAction definition code for javax.swing.text.StyledEditorKit.UnderlineAction
Enclosing class:
StyledEditorKit sample code for javax.swing.text.StyledEditorKit definition code for javax.swing.text.StyledEditorKit

public abstract static class StyledEditorKit.StyledTextAction
extends TextAction sample code for javax.swing.text.TextAction definition code for javax.swing.text.TextAction

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 XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction
changeSupport sample code for javax.swing.AbstractAction.changeSupport definition code for javax.swing.AbstractAction.changeSupport , enabled sample code for javax.swing.AbstractAction.enabled definition code for javax.swing.AbstractAction.enabled
 
Fields inherited from interface javax.swing.Action sample code for javax.swing.Action definition code for javax.swing.Action
ACCELERATOR_KEY sample code for javax.swing.Action.ACCELERATOR_KEY definition code for javax.swing.Action.ACCELERATOR_KEY , ACTION_COMMAND_KEY sample code for javax.swing.Action.ACTION_COMMAND_KEY definition code for javax.swing.Action.ACTION_COMMAND_KEY , DEFAULT sample code for javax.swing.Action.DEFAULT definition code for javax.swing.Action.DEFAULT , LONG_DESCRIPTION sample code for javax.swing.Action.LONG_DESCRIPTION definition code for javax.swing.Action.LONG_DESCRIPTION , MNEMONIC_KEY sample code for javax.swing.Action.MNEMONIC_KEY definition code for javax.swing.Action.MNEMONIC_KEY , NAME sample code for javax.swing.Action.NAME definition code for javax.swing.Action.NAME , SHORT_DESCRIPTION sample code for javax.swing.Action.SHORT_DESCRIPTION definition code for javax.swing.Action.SHORT_DESCRIPTION , SMALL_ICON sample code for javax.swing.Action.SMALL_ICON definition code for javax.swing.Action.SMALL_ICON
 
Constructor Summary
StyledEditorKit.StyledTextAction sample code for javax.swing.text.StyledEditorKit.StyledTextAction.StyledEditorKit.StyledTextAction(java.lang.String) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.StyledEditorKit.StyledTextAction(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  nm)
          Creates a new StyledTextAction from a string action name.
 
Method Summary
protected  JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane getEditor sample code for javax.swing.text.StyledEditorKit.StyledTextAction.getEditor(java.awt.event.ActionEvent) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.getEditor(java.awt.event.ActionEvent) (ActionEvent sample code for java.awt.event.ActionEvent definition code for java.awt.event.ActionEvent  e)
          Gets the target editor for an action.
protected  StyledDocument sample code for javax.swing.text.StyledDocument definition code for javax.swing.text.StyledDocument getStyledDocument sample code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledDocument(javax.swing.JEditorPane) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledDocument(javax.swing.JEditorPane) (JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  e)
          Gets the document associated with an editor pane.
protected  StyledEditorKit sample code for javax.swing.text.StyledEditorKit definition code for javax.swing.text.StyledEditorKit getStyledEditorKit sample code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledEditorKit(javax.swing.JEditorPane) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledEditorKit(javax.swing.JEditorPane) (JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  e)
          Gets the editor kit associated with an editor pane.
protected  void setCharacterAttributes sample code for javax.swing.text.StyledEditorKit.StyledTextAction.setCharacterAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.setCharacterAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean) (JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  editor, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr, boolean replace)
          Applies the given attributes to character content.
protected  void setParagraphAttributes sample code for javax.swing.text.StyledEditorKit.StyledTextAction.setParagraphAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.setParagraphAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean) (JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  editor, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr, boolean replace)
          Applies the given attributes to paragraphs.
 
Methods inherited from class javax.swing.text.TextAction sample code for javax.swing.text.TextAction definition code for javax.swing.text.TextAction
augmentList sample code for javax.swing.text.TextAction.augmentList(javax.swing.Action[], javax.swing.Action[]) definition code for javax.swing.text.TextAction.augmentList(javax.swing.Action[], javax.swing.Action[]) , getFocusedComponent sample code for javax.swing.text.TextAction.getFocusedComponent() definition code for javax.swing.text.TextAction.getFocusedComponent() , getTextComponent sample code for javax.swing.text.TextAction.getTextComponent(java.awt.event.ActionEvent) definition code for javax.swing.text.TextAction.getTextComponent(java.awt.event.ActionEvent)
 
Methods inherited from class javax.swing.AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction
addPropertyChangeListener sample code for javax.swing.AbstractAction.addPropertyChangeListener(java.beans.PropertyChangeListener) definition code for javax.swing.AbstractAction.addPropertyChangeListener(java.beans.PropertyChangeListener) , clone sample code for javax.swing.AbstractAction.clone() definition code for javax.swing.AbstractAction.clone() , firePropertyChange sample code for javax.swing.AbstractAction.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) definition code for javax.swing.AbstractAction.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) , getKeys sample code for javax.swing.AbstractAction.getKeys() definition code for javax.swing.AbstractAction.getKeys() , getPropertyChangeListeners sample code for javax.swing.AbstractAction.getPropertyChangeListeners() definition code for javax.swing.AbstractAction.getPropertyChangeListeners() , getValue sample code for javax.swing.AbstractAction.getValue(java.lang.String) definition code for javax.swing.AbstractAction.getValue(java.lang.String) , isEnabled sample code for javax.swing.AbstractAction.isEnabled() definition code for javax.swing.AbstractAction.isEnabled() , putValue sample code for javax.swing.AbstractAction.putValue(java.lang.String, java.lang.Object) definition code for javax.swing.AbstractAction.putValue(java.lang.String, java.lang.Object) , removePropertyChangeListener sample code for javax.swing.AbstractAction.removePropertyChangeListener(java.beans.PropertyChangeListener) definition code for javax.swing.AbstractAction.removePropertyChangeListener(java.beans.PropertyChangeListener) , setEnabled sample code for javax.swing.AbstractAction.setEnabled(boolean) definition code for javax.swing.AbstractAction.setEnabled(boolean)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 
Methods inherited from interface java.awt.event.ActionListener sample code for java.awt.event.ActionListener definition code for java.awt.event.ActionListener
actionPerformed sample code for java.awt.event.ActionListener.actionPerformed(java.awt.event.ActionEvent) definition code for java.awt.event.ActionListener.actionPerformed(java.awt.event.ActionEvent)
 

Constructor Detail

StyledEditorKit.StyledTextAction sample code for javax.swing.text.StyledEditorKit.StyledTextAction(java.lang.String) definition code for javax.swing.text.StyledEditorKit.StyledTextAction(java.lang.String)

public StyledEditorKit.StyledTextAction(String sample code for java.lang.String definition code for java.lang.String  nm)
Creates a new StyledTextAction from a string action name.

Parameters:
nm - the name of the action
Method Detail

getEditor sample code for javax.swing.text.StyledEditorKit.StyledTextAction.getEditor(java.awt.event.ActionEvent) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.getEditor(java.awt.event.ActionEvent)

protected final JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  getEditor(ActionEvent sample code for java.awt.event.ActionEvent definition code for java.awt.event.ActionEvent  e)
Gets the target editor for an action.

Parameters:
e - the action event
Returns:
the editor

getStyledDocument sample code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledDocument(javax.swing.JEditorPane) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledDocument(javax.swing.JEditorPane)

protected final StyledDocument sample code for javax.swing.text.StyledDocument definition code for javax.swing.text.StyledDocument  getStyledDocument(JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  e)
Gets the document associated with an editor pane.

Parameters:
e - the editor
Returns:
the document
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - for the wrong document type

getStyledEditorKit sample code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledEditorKit(javax.swing.JEditorPane) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.getStyledEditorKit(javax.swing.JEditorPane)

protected final StyledEditorKit sample code for javax.swing.text.StyledEditorKit definition code for javax.swing.text.StyledEditorKit  getStyledEditorKit(JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  e)
Gets the editor kit associated with an editor pane.

Parameters:
e - the editor pane
Returns:
the kit
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - for the wrong document type

setCharacterAttributes sample code for javax.swing.text.StyledEditorKit.StyledTextAction.setCharacterAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.setCharacterAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean)

protected final void setCharacterAttributes(JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  editor,
                                            AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.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 - the editor
attr - the attributes
replace - if true, then replace the existing attributes first

setParagraphAttributes sample code for javax.swing.text.StyledEditorKit.StyledTextAction.setParagraphAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean) definition code for javax.swing.text.StyledEditorKit.StyledTextAction.setParagraphAttributes(javax.swing.JEditorPane, javax.swing.text.AttributeSet, boolean)

protected final void setParagraphAttributes(JEditorPane sample code for javax.swing.JEditorPane definition code for javax.swing.JEditorPane  editor,
                                            AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.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 - the editor
attr - the attributes
replace - if true, replace the existing attributes first