Module java.desktop

Class HTMLEditorKit.HTMLTextAction

所有已实现的接口:
ActionListener, Serializable, Cloneable, EventListener, Action
直接已知的子类:
HTMLEditorKit.InsertHTMLTextAction
封装类:
HTMLEditorKit

public abstract static class HTMLEditorKit.HTMLTextAction extends StyledEditorKit.StyledTextAction
一个抽象的Action,提供一些方便的方法,可用于将HTML插入到现有文档中。

注意: 所有方便的方法都不会锁定文档。如果您有另一个线程修改文本,这些方法可能会表现不一致,或者返回错误的内容。

  • Constructor Details

    • HTMLTextAction

      public HTMLTextAction(String name)
      从字符串动作名称创建一个新的HTMLTextAction。
      参数:
      name - 动作的名称
  • Method Details

    • getHTMLDocument

      protected HTMLDocument getHTMLDocument(JEditorPane e)
      返回给定JEditorPaneHTMLDocument
      参数:
      e - JEditorPane
      返回:
      e的HTMLDocument。
    • getHTMLEditorKit

      protected HTMLEditorKit getHTMLEditorKit(JEditorPane e)
      返回给定JEditorPaneHTMLEditorKit
      参数:
      e - JEditorPane
      返回:
      e的HTMLEditorKit。
    • getElementsAt

      protected Element[] getElementsAt(HTMLDocument doc, int offset)
      返回包含offset的元素数组。第一个元素对应根元素。
      参数:
      doc - HTMLDocument的一个实例
      offset - 偏移值
      返回:
      包含offset的元素数组
    • elementCountToTag

      protected int elementCountToTag(HTMLDocument doc, int offset, HTML.Tag tag)
      返回元素数量,从最深的叶子开始,直到找到表示tag的元素为止。如果找不到表示tag的元素,则返回-1;如果位于offset处的叶子的父级表示tag,则返回0。
      参数:
      doc - HTMLDocument的一个实例
      offset - 起始偏移量
      tag - 要表示的标签
      返回:
      元素数量
    • findElementMatchingTag

      protected Element findElementMatchingTag(HTMLDocument doc, int offset, HTML.Tag tag)
      返回匹配tagoffset处的最深元素。
      参数:
      doc - HTMLDocument的一个实例
      offset - 指定的偏移量 >= 0
      tag - HTML.Tag的一个实例
      返回:
      最深的元素