- java.lang.Object
-
- javax.swing.AbstractAction
-
- javax.swing.text.TextAction
-
- javax.swing.text.StyledEditorKit.StyledTextAction
-
- All Implemented Interfaces:
-
ActionListener,Serializable,Cloneable,EventListener,Action
- 已知直接子类:
-
HTMLEditorKit.HTMLTextAction,StyledEditorKit.AlignmentAction,StyledEditorKit.BoldAction,StyledEditorKit.FontFamilyAction,StyledEditorKit.FontSizeAction,StyledEditorKit.ForegroundAction,StyledEditorKit.ItalicAction,StyledEditorKit.UnderlineAction
- Enclosing class:
- StyledEditorKit
public abstract static class StyledEditorKit.StyledTextAction extends TextAction
一个假定它被安装在一个带有StyledEditorKit(或子类)的JEditorPane上被触发的动作。 这有一些方便的方法来引起角色或段落级别的属性更改。 如果StyledDocument,JEditorPane或StyledEditorKit的假设不成立,那么方便方法将抛出IllegalArgumentException异常。如果源可以缩小为JEditorPane类型,则动作所采取行动的组件将成为ActionEvent的源。 如果源无法缩小,则最近重点关注的文本组件将被更改。 如果这些都不是这种情况,则无法执行该操作。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已被添加到
java.beans软件包中。 请参阅XMLEncoder。- 另请参见:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
构造方法摘要
构造方法 Constructor 描述 StyledTextAction(String nm)从字符串操作名称创建一个新的StyledTextAction。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 protected JEditorPanegetEditor(ActionEvent e)获取操作的目标编辑器。protected StyledDocumentgetStyledDocument(JEditorPane e)获取与编辑器窗格关联的文档。protected StyledEditorKitgetStyledEditorKit(JEditorPane e)获取与编辑器窗格相关联的编辑工具包。protected voidsetCharacterAttributes(JEditorPane editor, AttributeSet attr, boolean replace)将给定的属性应用于字符内容。protected voidsetParagraphAttributes(JEditorPane editor, AttributeSet attr, boolean replace)将给定的属性应用于段落。-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class javax.swing.text.TextAction
augmentList, getFocusedComponent, getTextComponent
-
-
-
-
构造方法详细信息
-
StyledTextAction
public StyledTextAction(String nm)
从字符串操作名称创建一个新的StyledTextAction。- 参数
-
nm- 动作的名称
-
-
方法详细信息
-
getEditor
protected final JEditorPane getEditor(ActionEvent e)
获取操作的目标编辑器。- 参数
-
e- 动作事件 - 结果
- 编辑
-
getStyledDocument
protected final StyledDocument getStyledDocument(JEditorPane e)
获取与编辑器窗格关联的文档。- 参数
-
e- 编辑 - 结果
- 文件
- 异常
-
IllegalArgumentException- 对于错误的文档类型
-
getStyledEditorKit
protected final StyledEditorKit getStyledEditorKit(JEditorPane e)
获取与编辑器窗格相关联的编辑工具包。- 参数
-
e- 编辑器窗格 - 结果
- 该套件
- 异常
-
IllegalArgumentException- 错误的文档类型
-
setCharacterAttributes
protected final void setCharacterAttributes(JEditorPane editor, AttributeSet attr, boolean replace)
将给定的属性应用于字符内容。 如果有选择,属性将应用于选择范围。 如果没有选择,则属性将应用于输入属性集,该属性集定义任何插入的新文本的属性。- 参数
-
editor- 编辑 -
attr- 属性 -
replace- 如果为true,则先替换现有属性
-
setParagraphAttributes
protected final void setParagraphAttributes(JEditorPane editor, AttributeSet attr, boolean replace)
将给定的属性应用于段落。 如果有选择,属性将应用于与选择相交的段落。 如果没有选择,属性将应用于当前插入符位置的段落。- 参数
-
editor- 编辑 -
attr- 属性 -
replace- 如果为true,replace替换现有属性
-
-