public class HTMLEditorKit extends StyledEditorKit implements Accessible
HTML EditorKit提供了几个目标,这些对HTML进行建模的方式有影响。 这些都以实质的方式影响了其设计。
 HTML的建模由HTMLDocument课程HTMLDocument 。 其文档描述了HTML如何建模的细节。 编辑支持充分利用文本包。 
HTMLFactory类提供。 这可以通过子类化或替换HTMLFactory并重新实现getViewFactory方法来返回替代工厂来轻松更改。 JEditorPane.setPage加载异步加载的JEditorPane.setPage 。 
         这由文档上的属性控制。 
         方法createDefaultDocument可以被覆盖以改变这一点。 
         工作的批量由HTMLDocument.HTMLReader课程完成。 
         实际工作由文本包中的DefaultStyledDocument和AbstractDocument类完成。 
         对此的支持由StyleSheet课程提供。 在EditorKit上设置StyleSheet属性会严重影响HTML的呈现。 
| Modifier and Type | Class and Description | 
|---|---|
| static class  | HTMLEditorKit.HTMLFactory
              为HTML创建视图的工厂。 
             | 
| static class  | HTMLEditorKit.HTMLTextAction
              一个抽象的Action提供了一些方便的方法,可能有助于将HTML插入到现有文档中。 
             | 
| static class  | HTMLEditorKit.InsertHTMLTextAction
              InsertHTMLTextAction可用于将HTML的任意字符串插入到现有的HTML文档中。 
             | 
| static class  | HTMLEditorKit.LinkController
              在适当的时候,类可以观看关联的组件并在其上触发超链接事件。 
             | 
| static class  | HTMLEditorKit.Parser
              接口由解析器支持。 
             | 
| static class  | HTMLEditorKit.ParserCallback
              解析的结果驱动这些回调方法。 
             | 
StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineActionDefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction| Modifier and Type | Field and Description | 
|---|---|
| static String | BOLD_ACTION
              粗体动作标识符 
             | 
| static String | COLOR_ACTION
              颜色选择操作标识符颜色作为参数传递 
             | 
| static String | DEFAULT_CSS
              默认级联样式表文件,用于设置标签视图。 
             | 
| static String | FONT_CHANGE_BIGGER
              字体大小增加到下一个值动作标识符 
             | 
| static String | FONT_CHANGE_SMALLER
              字体大小减小到下一个值动作标识符 
             | 
| static String | IMG_ALIGN_BOTTOM
              将图像对齐在底部。 
             | 
| static String | IMG_ALIGN_MIDDLE
              在中间对齐图像。 
             | 
| static String | IMG_ALIGN_TOP
              将图像对齐在顶部。 
             | 
| static String | IMG_BORDER
              在边框对齐图像。 
             | 
| static String | ITALIC_ACTION
              斜体动作标识符 
             | 
| static String | LOGICAL_STYLE_ACTION
              逻辑样式选择动作标识符逻辑样式作为参数传入 
             | 
| static String | PARA_INDENT_LEFT
              段落为缩进动作标识符 
             | 
| static String | PARA_INDENT_RIGHT
              段落正确的缩进动作标识符 
             | 
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction| Constructor and Description | 
|---|
| HTMLEditorKit()
              构造一个HTMLEditorKit,创建一个StyleContext,并加载样式表。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| Object | clone()
              创建一个编辑工具包的副本。 
             | 
| Document | createDefaultDocument()
              创建适用于此类型编辑器的未初始化文本存储模型。 
             | 
| protected void | createInputAttributes(Element element, MutableAttributeSet set)
              将 
              element的AttributeSet中的键/值复制到set。 | 
| void | deinstall(JEditorPane c)
              当该套件从JEditorPane中删除时调用。 
             | 
| AccessibleContext | getAccessibleContext()
              返回与此编辑器工具包关联的AccessibleContext 
             | 
| Action[] | getActions()
              获取编辑器命令列表。 
             | 
| String | getContentType()
              获取此套件代表支持的数据的MIME类型。 
             | 
| Cursor | getDefaultCursor()
              返回默认游标。 
             | 
| MutableAttributeSet | getInputAttributes()
              获取用于样式编辑操作的输入属性。 
             | 
| Cursor | getLinkCursor()
              返回光标以超链接使用。 
             | 
| protected HTMLEditorKit.Parser | getParser()
              获取解析器以用于读取HTML流。 
             | 
| StyleSheet | getStyleSheet()
              获取当前用于呈现HTML元素的一组样式。 
             | 
| ViewFactory | getViewFactory()
              获取适合产生由该套件生产的任何型号的视图的工厂。 
             | 
| void | insertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag)
              将HTML插入到现有文档中。 
             | 
| void | install(JEditorPane c)
              当该套件安装到JEditorPane中时调用。 
             | 
| boolean | isAutoFormSubmission()
              指示是自动处理html表单提交还是仅 
              FormSubmitEvent。 | 
| void | read(Reader in, Document doc, int pos)
              从给定的流插入内容。 
             | 
| void | setAutoFormSubmission(boolean isAuto)
              指定是否自动处理html表单提交或仅 
              FormSubmitEvent。 | 
| void | setDefaultCursor(Cursor cursor)
              设置默认光标。 
             | 
| void | setLinkCursor(Cursor cursor)
              将光标设置为使用链接。 
             | 
| void | setStyleSheet(StyleSheet s)
              设置用于渲染各种HTML元素的样式集。 
             | 
| void | write(Writer out, Document doc, int pos, int len)
              将内容从文档以适合此类内容处理程序的格式写入给定流。 
             | 
getCharacterAttributeRuncreateCaret, read, writepublic static final String DEFAULT_CSS
public static final String BOLD_ACTION
public static final String ITALIC_ACTION
public static final String PARA_INDENT_LEFT
public static final String PARA_INDENT_RIGHT
public static final String FONT_CHANGE_BIGGER
public static final String FONT_CHANGE_SMALLER
public static final String COLOR_ACTION
public static final String LOGICAL_STYLE_ACTION
public static final String IMG_ALIGN_TOP
public static final String IMG_ALIGN_MIDDLE
public static final String IMG_ALIGN_BOTTOM
public static final String IMG_BORDER
public String getContentType()
text/html 。 
          getContentType在 
            DefaultEditorKit 
           public ViewFactory getViewFactory()
getViewFactory在 
            StyledEditorKit 
           public Document createDefaultDocument()
createDefaultDocument在 
            StyledEditorKit 
           public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
doc是doc的一个实例,这将读取HTML 3.2文本。 
           将HTML插入非空文档必须位于主体元素内,如果不插入到正文中,将抛出异常。 
           当插入非空文档时,身体之外的所有标签(头,标题)将被删除。 
          read在 
            DefaultEditorKit 
           in - 要读取的流 
           doc - 插入的目的地 
           pos - 放置内容的文档中的位置 
           IOException - 在任何I / O错误 
           BadLocationException - 如果pos表示文档中的无效位置 
           RuntimeException - (最终将是一个BadLocationException)如果pos无效 
           public void insertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag) throws BadLocationException, IOException
doc - 要插入的文件 
           offset - 插入HTML的偏移量 
           popDepth - 插入之前要生成的ElementSpec.EndTagTypes的数量 
           pushDepth - 
            pushDepth的数量,其方向为ElementSpec.JoinNextDirection,应该在插入之前生成,但在生成结束标签之后 
           insertTag - 开始插入文档的第一个标签 
           RuntimeException - (最终将是一个BadLocationException)如果pos无效 
           BadLocationException 
           IOException 
           public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
write在 
            DefaultEditorKit 
           out - 要写入的流 
           doc - 写的来源 
           pos - 文档中获取内容的位置 
           len - 写出的金额 
           IOException - 在任何I / O错误 
           BadLocationException - 如果pos表示文档中的无效位置 
           public void install(JEditorPane c)
install在 
            StyledEditorKit 
           c - JEditorPane 
           public void deinstall(JEditorPane c)
deinstall在 
            StyledEditorKit类 
           c - JEditorPane 
           public void setStyleSheet(StyleSheet s)
public StyleSheet getStyleSheet()
public Action[] getActions()
getActions在 
            StyledEditorKit 
           protected void createInputAttributes(Element element, MutableAttributeSet set)
element的AttributeSet中的键/值复制到set 。 
           这不会复制组件,图标或元素名称属性。 
           子类可能希望改进什么是什么和什么不复制在这里。 
           但请确保先删除set中的所有set 。 
           随时插入符号在不同位置移动即可。
public MutableAttributeSet getInputAttributes()
getInputAttributes在 
            StyledEditorKit 
           public void setDefaultCursor(Cursor cursor)
public Cursor getDefaultCursor()
public void setLinkCursor(Cursor cursor)
public Cursor getLinkCursor()
public boolean isAutoFormSubmission()
FormSubmitEvent 。 
          setAutoFormSubmission(boolean) 
           public void setAutoFormSubmission(boolean isAuto)
FormSubmitEvent 。 
           默认设置为true。 
          isAutoFormSubmission() , FormSubmitEvent 
           public Object clone()
clone在 
            StyledEditorKit 
           Cloneable 
           protected HTMLEditorKit.Parser getParser()
public AccessibleContext getAccessibleContext()
getAccessibleContext在接口 
            Accessible 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.