📄 document.html
字号:
</DD></DL><HR><A NAME="remove(int, int)"><!-- --></A><H3>remove</H3><PRE>public void <B>remove</B>(int offs, int len) throws <A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></PRE><DL><DD>Removes a portion of the content of the document. This will cause a DocumentEvent of type DocumentEvent.EventType.REMOVE to be sent to the registered DocumentListeners, unless an exception is thrown. The notification will be sent to the listeners by calling the removeUpdate method on the DocumentListeners. <p> To ensure reasonable behavior in the face of concurrency, the event is dispatched after the mutation has occurred. This means that by the time a notification of removal is dispatched, the document has already been updated and any marks created by createPosition have already changed. For a removal, the end of the removal range is collapsed down to the start of the range, and any marks in the removal range are collapsed down to the start of the range. <p align=center><img src="doc-files/Document-remove.gif"> <p> If the Document structure changed as result of the removal, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to a remove. <p> If the Document supports undo/redo, an UndoableEditEvent will also be generated.<DD><DL><DT><B>Parameters:</B><DD><CODE>offs</CODE> - the offset from the begining >= 0<DD><CODE>len</CODE> - the number of characters to remove >= 0<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></CODE> - some portion of the removal range was not a valid part of the document. The location in the exception is the first bad position encountered.<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/event/DocumentEvent.html"><CODE>DocumentEvent</CODE></A>, <A HREF="../../../javax/swing/event/DocumentListener.html"><CODE>DocumentListener</CODE></A>, <A HREF="../../../javax/swing/event/UndoableEditEvent.html"><CODE>UndoableEditEvent</CODE></A>, <A HREF="../../../javax/swing/event/UndoableEditListener.html"><CODE>UndoableEditListener</CODE></A></DL></DD></DL><HR><A NAME="insertString(int, java.lang.String, javax.swing.text.AttributeSet)"><!-- --></A><H3>insertString</H3><PRE>public void <B>insertString</B>(int offset, <A HREF="../../../java/lang/String.html">String</A> str, <A HREF="../../../javax/swing/text/AttributeSet.html">AttributeSet</A> a) throws <A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></PRE><DL><DD>Inserts a string of content. This will cause a DocumentEvent of type DocumentEvent.EventType.INSERT to be sent to the registered DocumentListers, unless an exception is thrown. The DocumentEvent will be delivered by calling the insertUpdate method on the DocumentListener. The offset and length of the generated DocumentEvent will indicate what change was actually made to the Document. <p align=center><img src="doc-files/Document-insert.gif"> <p> If the Document structure changed as result of the insertion, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to an insertion. <p> If the Document supports undo/redo, an UndoableEditEvent will also be generated.<DD><DL><DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset into the document to insert the content >= 0. All positions that track change at or after the given location will move.<DD><CODE>str</CODE> - the string to insert<DD><CODE>a</CODE> - the attributes to associate with the inserted content. This may be null if there are no attributes.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></CODE> - the given insert position is not a valid position within the document<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/event/DocumentEvent.html"><CODE>DocumentEvent</CODE></A>, <A HREF="../../../javax/swing/event/DocumentListener.html"><CODE>DocumentListener</CODE></A>, <A HREF="../../../javax/swing/event/UndoableEditEvent.html"><CODE>UndoableEditEvent</CODE></A>, <A HREF="../../../javax/swing/event/UndoableEditListener.html"><CODE>UndoableEditListener</CODE></A></DL></DD></DL><HR><A NAME="getText(int, int)"><!-- --></A><H3>getText</H3><PRE>public <A HREF="../../../java/lang/String.html">String</A> <B>getText</B>(int offset, int length) throws <A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></PRE><DL><DD>Fetches the text contained within the given portion of the document.<DD><DL><DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset into the document representing the desired start of the text >= 0<DD><CODE>length</CODE> - the length of the desired string >= 0<DT><B>Returns:</B><DD>the text, in a String of length >= 0<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></CODE> - some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.</DL></DD></DL><HR><A NAME="getText(int, int, javax.swing.text.Segment)"><!-- --></A><H3>getText</H3><PRE>public void <B>getText</B>(int offset, int length, <A HREF="../../../javax/swing/text/Segment.html">Segment</A> txt) throws <A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></PRE><DL><DD>Fetches the text contained within the given portion of the document.<DD><DL><DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset into the document representing the desired start of the text >= 0<DD><CODE>length</CODE> - the length of the desired string >= 0<DD><CODE>txt</CODE> - the Segment object to return the text in<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></CODE> - Some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.</DL></DD></DL><HR><A NAME="getStartPosition()"><!-- --></A><H3>getStartPosition</H3><PRE>public <A HREF="../../../javax/swing/text/Position.html">Position</A> <B>getStartPosition</B>()</PRE><DL><DD>Returns a position that represents the start of the document. The position returned can be counted on to track change and stay located at the beginning of the document.<DD><DL><DT><B>Returns:</B><DD>the position</DL></DD></DL><HR><A NAME="getEndPosition()"><!-- --></A><H3>getEndPosition</H3><PRE>public <A HREF="../../../javax/swing/text/Position.html">Position</A> <B>getEndPosition</B>()</PRE><DL><DD>Returns a position that represents the end of the document. The position returned can be counted on to track change and stay located at the end of the document.<DD><DL><DT><B>Returns:</B><DD>the position</DL></DD></DL><HR><A NAME="createPosition(int)"><!-- --></A><H3>createPosition</H3><PRE>public <A HREF="../../../javax/swing/text/Position.html">Position</A> <B>createPosition</B>(int offs) throws <A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></PRE><DL><DD>This method allows an application to mark a place in a sequence of character content. This mark can then be used to tracks change as insertions and removals are made in the content. The policy is that insertions always occur prior to the current position (the most common case) unless the insertion location is zero, in which case the insertion is forced to a position that follows the original position.<DD><DL><DT><B>Parameters:</B><DD><CODE>offs</CODE> - the offset from the start of the document >= 0<DT><B>Returns:</B><DD>the position<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></CODE> - if the given position does not represent a valid location in the associated document</DL></DD></DL><HR><A NAME="getRootElements()"><!-- --></A><H3>getRootElements</H3><PRE>public <A HREF="../../../javax/swing/text/Element.html">Element</A>[] <B>getRootElements</B>()</PRE><DL><DD>Returns all of the root elements that are defined. <p> Typically there will be only one document structure, but the interface supports building an arbitrary number of structural projections over the text data. The document can have multiple root elements to support multiple document structures. Some examples might be: </p> <ul> <li>Text direction. <li>Lexical token streams. <li>Parse trees. <li>Conversions to formats other than the native format. <li>Modification specifications. <li>Annotations. </ul><DD><DL><DT><B>Returns:</B><DD>the root element</DL></DD></DL><HR><A NAME="getDefaultRootElement()"><!-- --></A><H3>getDefaultRootElement</H3><PRE>public <A HREF="../../../javax/swing/text/Element.html">Element</A> <B>getDefaultRootElement</B>()</PRE><DL><DD>Returns the root element that views should be based upon, unless some other mechanism for assigning views to element structures is provided.<DD><DL><DT><B>Returns:</B><DD>the root element</DL></DD></DL><HR><A NAME="render(java.lang.Runnable)"><!-- --></A><H3>render</H3><PRE>public void <B>render</B>(<A HREF="../../../java/lang/Runnable.html">Runnable</A> r)</PRE><DL><DD>This allows the model to be safely rendered in the presence of currency, if the model supports being updated asynchronously. The given runnable will be executed in a way that allows it to safely read the model with no changes while the runnable is being executed. The runnable itself may <em>not</em> make any mutations.<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - a Runnable used to render the model</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_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/Document.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/Caret.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/swing/text/Element.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="Document.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -