📄 htmleditorkit.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:42:34 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class HTMLEditorKit</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/HTMLEditorKit.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../javax/swing/text/html/HTMLDocument.RunElement.html"><B>PREV CLASS</B></A> <A HREF="../../../../javax/swing/text/html/HTMLEditorKit.HTMLFactory.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="HTMLEditorKit.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#inner_class_summary">INNER</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.swing.text.html</FONT><BR>Class HTMLEditorKit</H2><PRE><A HREF="../../../../java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../../../../javax/swing/text/EditorKit.html">javax.swing.text.EditorKit</A> | +--<A HREF="../../../../javax/swing/text/DefaultEditorKit.html">javax.swing.text.DefaultEditorKit</A> | +--<A HREF="../../../../javax/swing/text/StyledEditorKit.html">javax.swing.text.StyledEditorKit</A> | +--<B>javax.swing.text.html.HTMLEditorKit</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../java/lang/Cloneable.html">Cloneable</A>, <A HREF="../../../../java/io/Serializable.html">Serializable</A></DD></DL><HR><DL><DT>public class <B>HTMLEditorKit</B><DT>extends <A HREF="../../../../javax/swing/text/StyledEditorKit.html">StyledEditorKit</A></DL><P>The Swing JEditorPane text component supports different kinds of content via a plug-in mechanism called an EditorKit. Because HTML is a very popular format of content, some support is provided by default. The default support is provided by this class, which supports HTML version 3.2 (with some extensions), and is migrating toward version 4.0. The <applet> tag is not supported, but some support is provided for the <object> tag. <p> There are several goals of the HTML EditorKit provided, that have an effect upon the way that HTML is modeled. These have influenced its design in a substantial way. <dl> <p> <dt> Support editing <dd> It might seem fairly obvious that a plug-in for JEditorPane should provide editing support, but that fact has several design considerations. There are a substantial number of HTML documents that don't properly conform to an HTML specification. These must be normalized somewhat into a correct form if one is to edit them. Additionally, users don't like to be presented with an excessive amount of structure editing, so using traditional text editing gestures is preferred over using the HTML structure exactly as defined in the HTML document. <p> The modeling of HTML is provided by the class <code>HTMLDocument</code>. Its documention describes the details of how the HTML is modeled. The editing support leverages heavily off of the text package. <p> <dt> Extendable/Scalable <dd> To maximize the usefulness of this kit, a great deal of effort has gone into making it extendable. These are some of the features. <ol> <li> The parser is replacable. The default parser is the Hot Java parser which is DTD based. A different DTD can be used, or an entirely different parser can be used. To change the parser, reimplement the getParser method. The default parser is dynamically loaded when first asked for, so the class files will never be loaded if an alternative parser is used. The default parser is in a seperate package called parser below this package. <li> The parser drives the ParserCallback, which is provided by HTMLDocument. To change the callback, subclass HTMLDocument and reimplement the createDefaultDocument method to return document that produces a different reader. The reader controls how the document is structured. Although the Document provides HTML support by default, there is nothing preventing support of non-HTML tags that result in alternative element structures. <li> The default view of the models are provided as a hierarchy of View implementations, so one can easily customize how a particular element is displayed or add capabilities for new kinds of elements by providing new View implementations. The default set of views are provided by the <code>HTMLFactory</code> class. This can be easily changed by subclassing or replacing the HTMLFactory and reimplementing the getViewFactory method to return the alternative factory. <li> The View implementations work primarily off of CSS attributes, which are kept in the views. This makes it possible to have multiple views mapped over the same model that appear substantially different. This can be especially useful for printing. For most HTML attributes, the HTML attributes are converted to CSS attributes for display. This helps make the View implementations more general purpose </ol> <p> <dt> Asynchronous Loading <dd> Larger documents involve a lot of parsing and take some time to load. By default, this kit produces documents that will be loaded asynchronously if loaded using <code>JEditorPane.setPage</code>. This is controlled by a property on the document. The method <a href="#createDefaultDocument">createDefaultDocument</a> can be overriden to change this. The batching of work is done by the <code>HTMLDocument.HTMLReader</code> class. The actual work is done by the <code>DefaultStyledDocument</code> and <code>AbstractDocument</code> classes in the text package. <p> <dt> Customization from current LAF <dd> HTML provides a well known set of features without exactly specifying the display characteristics. Swing has a theme mechanism for its look-and-feel implementations. It is desirable for the look-and-feel to feed display characteristics into the HTML views. An user with poor vision for example would want high contrast and larger than typical fonts. <p> The support for this is provided by the <code>StyleSheet</code> class. The presentation of the HTML can be heavily influenced by the setting of the StyleSheet property on the EditorKit. <p> <dt> Not lossy <dd> An EditorKit has the ability to be read and save documents. It is generally the most pleasing to users if there is no loss of data between the two operation. The policy of the HTMLEditorKit will be to store things not recognized or not necessarily visible so they can be subsequently written out. The model of the HTML document should therefore contain all information discovered while reading the document. This is constrained in some ways by the need to support editing (i.e. incorrect documents sometimes must be normalized). The guiding principle is that information shouldn't be lost, but some might be synthesized to produce a more correct model or it might be rearranged. </dl><P><DL><DT><B>See Also: </B><DD><A HREF="../../../../serialized-form.html#javax.swing.text.html.HTMLEditorKit">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_class_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Inner Class Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/HTMLEditorKit.HTMLFactory.html">HTMLEditorKit.HTMLFactory</A></B></CODE><BR> A factory to build views for HTML.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/HTMLEditorKit.HTMLTextAction.html">HTMLEditorKit.HTMLTextAction</A></B></CODE><BR> An abstract Action providing some convenience methods that may be useful in inserting HTML into an existing document.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/HTMLEditorKit.InsertHTMLTextAction.html">HTMLEditorKit.InsertHTMLTextAction</A></B></CODE><BR> InsertHTMLTextAction can be used to insert an arbitrary string of HTML into an existing HTML document.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/HTMLEditorKit.LinkController.html">HTMLEditorKit.LinkController</A></B></CODE><BR> Class to watch the associated component and fire hyperlink events on it when appropriate.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/HTMLEditorKit.Parser.html">HTMLEditorKit.Parser</A></B></CODE><BR> Interface to be supported by the parser.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/HTMLEditorKit.ParserCallback.html">HTMLEditorKit.ParserCallback</A></B></CODE><BR> The result of parsing drives these callback methods.</TD></TR></TABLE> <A NAME="inner_classes_inherited_from_class_javax.swing.text.StyledEditorKit"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class javax.swing.text.<A HREF="../../../../javax/swing/text/StyledEditorKit.html">StyledEditorKit</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../../javax/swing/text/StyledEditorKit.AlignmentAction.html">StyledEditorKit.AlignmentAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.BoldAction.html">StyledEditorKit.BoldAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.FontFamilyAction.html">StyledEditorKit.FontFamilyAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.FontSizeAction.html">StyledEditorKit.FontSizeAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.ForegroundAction.html">StyledEditorKit.ForegroundAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.ItalicAction.html">StyledEditorKit.ItalicAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.StyledTextAction.html">StyledEditorKit.StyledTextAction</A>, <A HREF="../../../../javax/swing/text/StyledEditorKit.UnderlineAction.html">StyledEditorKit.UnderlineAction</A></CODE></TD></TR></TABLE> <A NAME="inner_classes_inherited_from_class_javax.swing.text.DefaultEditorKit"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class javax.swing.text.<A HREF="../../../../javax/swing/text/DefaultEditorKit.html">DefaultEditorKit</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../../javax/swing/text/DefaultEditorKit.BeepAction.html">DefaultEditorKit.BeepAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.CopyAction.html">DefaultEditorKit.CopyAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.CutAction.html">DefaultEditorKit.CutAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.DefaultKeyTypedAction.html">DefaultEditorKit.DefaultKeyTypedAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.InsertBreakAction.html">DefaultEditorKit.InsertBreakAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.InsertContentAction.html">DefaultEditorKit.InsertContentAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.InsertTabAction.html">DefaultEditorKit.InsertTabAction</A>, <A HREF="../../../../javax/swing/text/DefaultEditorKit.PasteAction.html">DefaultEditorKit.PasteAction</A></CODE></TD></TR></TABLE> <!-- =========== FIELD SUMMARY =========== -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -