⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 document.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!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:41:54 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface  Document</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>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Document.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../javax/swing/text/Caret.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<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>  &nbsp;&nbsp;<A HREF="Document.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<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</FONT><BR>Interface  Document</H2><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../javax/swing/text/AbstractDocument.html">AbstractDocument</A></DD></DL><HR><DL><DT>public interface <B>Document</B></DL><P><p> The Document is a container for text that serves as the model  for swing text components.  The goal for this interface is to scale from very simple needs (plain text textfield) to complex needs (HTML or XML documents for example). <p><b><font size=+1>Content</font></b> <p> At the simplest level, text can be  modeled as a linear sequence of characters. To support  internationalization, the Swing text model uses  <a href="http://www.unicode.org/">unicode</a> characters.  The sequence of characters displayed in a text component is  generally referred to as the component's <em>content</em>. <p> To refer to locations within the sequence, the coordinates used are the location between two characters.  As the diagram  below shows, a location in a text document can be referred to  as a position, or an offset. This position is zero-based. <p align=center><img src="doc-files/Document-coord.gif"> <p> In the example, if the content of a document is the sequence "The quick brown fox," as shown in the preceding diagram,  the location just before the word "The" is 0, and the location after  the word "The" and before the whitespace that follows it is 3.  The entire sequence of characters in the sequence "The" is called a  <em>range</em>. <p>The following methods give access to the character data that makes up the content. <ul> <li><a href="#getLength">getLength</a> <li><a href="#getText(int, int)">getText(int, int)</a> <li><a href="#getText(int, int, javax.swing.text.Segment)">getText(int, int, Segment)</a> </ul> <p><b><font size=+1>Structure</font></b> <p> Text is rarely represented simply as featureless content. Rather,  text typically has some sort of structure associated with it. Exactly what structure is modeled is up to a particular Document implementation.  It might be as simple as no structure (i.e. a simple text field), or it might be something like diagram below. <p align=center><img src="doc-files/Document-structure.gif"> <p> The unit of structure (i.e. a node of the tree) is referred to by the <a href="Element.html">Element</a> interface.  Each Element can be tagged with a set of attributes.  These attributes (name/value pairs) are defined by the  <a href="AttributeSet.html">AttributeSet</a> interface. <p>The following methods give access to the document structure. <ul> <li><a href="#getDefaultRootElement">getDefaultRootElement</a> <li><a href="#getRootElements">getRootElements</a> </ul> <p><b><font size=+1>Mutations</font></b> <p> All documents need to be able to add and remove simple text. Typically, text is inserted and removed via gestures from a keyboard or a mouse.  What effect the insertion or removal has upon the document structure is entirely up to the implementation of the document. <p>The following methods are related to mutation of the  document content: <ul> <li><a href="#insertString">insertString</a> <li><a href="#remove">remove</a> <li><a href="#createPosition">createPosition</a> </ul> <p><b><font size=+1>Notification</font></b> <p> Mutations to the Document must be communicated to interested observers.  The notification of change follows the event model guidelines that are specified for JavaBeans.  In the JavaBeans event model, once an event notification is dispatched, all listeners  must be notified before any further mutations occur to the source  of the event.  Further, order of delivery is not guaranteed. <p> Notification is provided as two seperate events,  <a href="../event/DocumentEvent.html">DocumentEvent<a>, and <a href="../event/UndoableEditEvent.html">UndoableEditEvent</a>. If a mutation is made to a Document through its api,  a DocumentEvent will be sent to all of the registered  DocumentListeners.  If the Document implementation supports  undo/redo capabilities, an UndoableEditEvent will be sent to all of the registered UndoableEditListeners. If an undoable edit is undone, a DocumentEvent should be fired from the Document to indicate it has changed again. In this case however, there should be no UndoableEditEvent generated since that edit is actually the source of the change rather than a mutation to the Document made through it's  api. <p align=center><img src="doc-files/Document-notification.gif"> <p> Referring to the above diagram, suppose that the component shown  on the left mutates the document object represented by the blue  rectangle. The document responds by dispatching a DocumentEvent to  both component views and sends an UndoableEditEvent to the listening  logic, which maintains a history buffer. <p> Now suppose that the component shown on the right mutates the same  document.  Again, the document dispatches a DocumentEvent to both  component views and sends an UndoableEditEvent to the listening logic  that is maintaining the history buffer.  <p> If the history buffer is then rolled back (i.e. the last UndoableEdit undone), a DocumentEvent is sent to both views, causing both of them to  reflect the undone mutation to the document (that is, the removal of the right component's mutation). If the history buffer again  rolls back another change, another DocumentEvent is sent to both views,  causing them to reflect the undone mutation to the document -- that is,  the removal of the left component's mutation.  <p> The methods related to observing mutations to the document are: <ul> <li><a href="#addDocumentListener">addDocumentListener</a> <li><a href="#removeDocumentListener">removeDocumentListener</a> <li><a href="#addUndoableEditListener">addUndoableEditListener</a> <li><a href="#removeUndoableEditListener">removeUndoableEditListener</a> </ul> <p><b><font size=+1>Properties</font></b> <p> Document implementations will generally have some set of properties associated with them at runtime.  Two well known properties are the <a href="#StreamDescriptionProperty">StreamDescriptionProperty</a> which can be used to describe where the Document came from, and <a href="#TitleProperty">TitleProperty</a> which can be used to name the Document.  The methods related to the properties are: <ul> <li><a href="#getProperty">getProperty</a> <li><a href="#putProperty">putProperty</a> </ul><P><DL><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>, <A HREF="../../../javax/swing/text/Element.html"><CODE>Element</CODE></A>, <A HREF="../../../javax/swing/text/Position.html"><CODE>Position</CODE></A>, <A HREF="../../../javax/swing/text/AttributeSet.html"><CODE>AttributeSet</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/text/Document.html#StreamDescriptionProperty">StreamDescriptionProperty</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The property name for the description of the stream used to initialize the document.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/text/Document.html#TitleProperty">TitleProperty</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The property name for the title of the document, if  there is one.</TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/text/Document.html#addDocumentListener(javax.swing.event.DocumentListener)">addDocumentListener</A></B>(<A HREF="../../../javax/swing/event/DocumentListener.html">DocumentListener</A>&nbsp;listener)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers the given observer to begin receiving notifications when changes are made to the document.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -