📄 htmldocument.html
字号:
<DL><DD>Creates the root element to be used to represent the default document structure.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../javax/swing/text/DefaultStyledDocument.html#createDefaultRoot()">createDefaultRoot</A></CODE> in class <CODE><A HREF="../../../../javax/swing/text/DefaultStyledDocument.html">DefaultStyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the element base</DL></DD></DL><HR><A NAME="setTokenThreshold(int)"><!-- --></A><H3>setTokenThreshold</H3><PRE>public void <B>setTokenThreshold</B>(int n)</PRE><DL><DD>Sets the number of tokens to buffer before trying to update the documents element structure.</DL><HR><A NAME="getTokenThreshold()"><!-- --></A><H3>getTokenThreshold</H3><PRE>public int <B>getTokenThreshold</B>()</PRE><DL><DD>Gets the number of tokens to buffer before trying to update the documents element structure. By default, this will be <code>Integer.MAX_VALUE</code>.</DL><HR><A NAME="setPreservesUnknownTags(boolean)"><!-- --></A><H3>setPreservesUnknownTags</H3><PRE>public void <B>setPreservesUnknownTags</B>(boolean preservesTags)</PRE><DL><DD>Sets how unknown tags are handled. If set to true, unknown tags are put in the model, otherwise they are dropped.</DL><HR><A NAME="getPreservesUnknownTags()"><!-- --></A><H3>getPreservesUnknownTags</H3><PRE>public boolean <B>getPreservesUnknownTags</B>()</PRE><DL><DD><DL><DT><B>Returns:</B><DD>true if unknown tags are to be preserved when parsing.</DL></DD></DL><HR><A NAME="processHTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent)"><!-- --></A><H3>processHTMLFrameHyperlinkEvent</H3><PRE>public void <B>processHTMLFrameHyperlinkEvent</B>(<A HREF="../../../../javax/swing/text/html/HTMLFrameHyperlinkEvent.html">HTMLFrameHyperlinkEvent</A> e)</PRE><DL><DD>Processes HyperlinkEvents that are generated by documents in an HTML frame. The HyperlinkEvent type, as the parameter suggests, is HTMLFrameHyperlinkEvent. In addition to the typical information contained in a HyperlinkEvent, this event contains the element that corresponds to the frame in which the click happened (the source element) and the target name. The target name has 4 possible values: <ul> <li> _self <li> _parent <li> _top <li> a named frame </ul> If target is _self, the action is to change the value of the HTML.Attribute.SRC attribute and fires a ChangedUpdate event. If the target is _parent, then it deletes the parent element, which is a <FRAMESET> element, and inserts a new <FRAME> element and sets its HTML.Attribute.SRC attribute to have a value equal to the destination URL and fire a RemovedUpdate and InsertUpdate. If the target is _top, this method does nothing. In the implementation of the view for a frame, namely the FrameView, the processing of _top is handled. Given that _top implies replacing the entire document, it made sense to handle this outside of the document that it will replace. If the target is a named frame, then the element hierarchy is searched for an element with a name equal to the target, its HTML.Attribute.SRC attribute is updated and a ChangedUpdate event is fired.<DD><DL><DT><B>Parameters:</B><DD><CODE>e</CODE> - the event</DL></DD></DL><HR><A NAME="setParser(javax.swing.text.html.HTMLEditorKit.Parser)"><!-- --></A><H3>setParser</H3><PRE>public void <B>setParser</B>(<A HREF="../../../../javax/swing/text/html/HTMLEditorKit.Parser.html">HTMLEditorKit.Parser</A> parser)</PRE><DL><DD>Sets the parser that is used by the methods that insert html into the existing document, eg <code>setInnerHTML</code>, <code>setOuterHTML</code>... <p> <code>HTMLEditorKit.createDefaultDocument</code> will set the parser for you. If you create an HTMLDocument by hand, be sure and set the parser accordingly.<DD><DL><DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><HR><A NAME="getParser()"><!-- --></A><H3>getParser</H3><PRE>public <A HREF="../../../../javax/swing/text/html/HTMLEditorKit.Parser.html">HTMLEditorKit.Parser</A> <B>getParser</B>()</PRE><DL><DD>Returns the parser that is used when inserting HTML into the existing document.<DD><DL><DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><HR><A NAME="setInnerHTML(javax.swing.text.Element, java.lang.String)"><!-- --></A><H3>setInnerHTML</H3><PRE>public void <B>setInnerHTML</B>(<A HREF="../../../../javax/swing/text/Element.html">Element</A> elem, <A HREF="../../../../java/lang/String.html">String</A> htmlText) throws <A HREF="../../../../javax/swing/text/BadLocationException.html">BadLocationException</A>, <A HREF="../../../../java/io/IOException.html">IOException</A></PRE><DL><DD>Replaces the children of the given element with the contents specified as an HTML string. <p>This will be seen as at least two events, n inserts followed by a remove. <p>For this to work correcty, the receiver must have an HTMLEditorKit.Parser set. This will be the case if the receiver was created from an HTMLEditorKit via the <code>createDefaultDocument</code> method.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - is <code>elem</code> is a leaf<DD><CODE><A HREF="../../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if an HTMLEditorKit.Parser has not been set on the receiver.<DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><HR><A NAME="setOuterHTML(javax.swing.text.Element, java.lang.String)"><!-- --></A><H3>setOuterHTML</H3><PRE>public void <B>setOuterHTML</B>(<A HREF="../../../../javax/swing/text/Element.html">Element</A> elem, <A HREF="../../../../java/lang/String.html">String</A> htmlText) throws <A HREF="../../../../javax/swing/text/BadLocationException.html">BadLocationException</A>, <A HREF="../../../../java/io/IOException.html">IOException</A></PRE><DL><DD>Replaces the given element in the parent with the contents specified as an HTML string. <p>This will be seen as at least two events, n inserts followed by a remove. <p>When replacing a leaf this will attempt to make sure there is a newline present if one is needed. This may result in an additional element being inserted. Consider, if you were to replace a character element that contained a newline with <img> this would create two elements, one for the image, ane one for the newline. <p>If you try to replace the element at length you will most likely end up with two elements, eg setOuterHTML(getCharacterElement (getLength()), "blah") will result in two leaf elements at the end, one representing 'blah', and the other representing the end element. <p>For this to work correcty, the receiver must have an HTMLEditorKit.Parser set. This will be the case if the receiver was created from an HTMLEditorKit via the <code>createDefaultDocument</code> method.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if an HTMLEditorKit.Parser has not been set on the receiver.<DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><HR><A NAME="insertAfterStart(javax.swing.text.Element, java.lang.String)"><!-- --></A><H3>insertAfterStart</H3><PRE>public void <B>insertAfterStart</B>(<A HREF="../../../../javax/swing/text/Element.html">Element</A> elem, <A HREF="../../../../java/lang/String.html">String</A> htmlText) throws <A HREF="../../../../javax/swing/text/BadLocationException.html">BadLocationException</A>, <A HREF="../../../../java/io/IOException.html">IOException</A></PRE><DL><DD>Inserts the HTML specified as a string at the start of the element. <p>For this to work correcty, the receiver must have an HTMLEditorKit.Parser set. This will be the case if the receiver was created from an HTMLEditorKit via the <code>createDefaultDocument</code> method.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if an HTMLEditorKit.Parser has not been set on the receiver.<DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><HR><A NAME="insertBeforeEnd(javax.swing.text.Element, java.lang.String)"><!-- --></A><H3>insertBeforeEnd</H3><PRE>public void <B>insertBeforeEnd</B>(<A HREF="../../../../javax/swing/text/Element.html">Element</A> elem, <A HREF="../../../../java/lang/String.html">String</A> htmlText) throws <A HREF="../../../../javax/swing/text/BadLocationException.html">BadLocationException</A>, <A HREF="../../../../java/io/IOException.html">IOException</A></PRE><DL><DD>Inserts the HTML specified as a string at the end of the element. <p> If <code>elem</code>'s children are leafs, at the character at a <code>elem.getEndOffset() - 1</code> is a newline, this will insert before the newline so that there isn't text after the newline. <p>For this to work correcty, the receiver must have an HTMLEditorKit.Parser set. This will be the case if the receiver was created from an HTMLEditorKit via the <code>createDefaultDocument</code> method.<DD><DL><DT><B>T
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -