📄 textapi.html
字号:
<tr><th>Interface or Class</th><th>Description</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html">Document</a> </td> <td>An interface that defines the API that must be implemented by all documents. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html">AbstractDocument</a> </td> <td>An abstract superclass implementation of the <code>Document</code> interface. This is the superclass for all documents provided by the Swing text package. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/PlainDocument.html">PlainDocument</a> </td> <td>A class that implements the <code>Document</code> interface. This is the default document for the plain text components (text field, password field, and text area). Additionally used by editor pane and text pane when loading plain text or text of an unknown format. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/StyledDocument.html">StyledDocument</a> </td> <td>A <code>Document</code> subinterface. Defines the API that must be implemented by documents that support styled text. <code>JTextPane</code> requires that its document be of this type. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/DefaultStyledDocument.html">DefaultStyledDocument</a> </td> <td>A class that implements the <code>StyledDocument</code> interface. The default document for <code>JTextPane</code>. </td> </tr></table><p><table border=1><caption><a name="docmethods">Working with Documents</a></caption><tr><th>Class or Method</th><th>Description</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/DocumentFilter.html">DocumentFilter</a> </td> <td>The superclass of all document filters. You can use a document filter to change what gets inserted or removed from a document, without having to implement a document yourself. See <a href="generaltext.html#filter"> Implementing a Document Filter</a>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html#setDocumentFilter(javax.swing.text.DocumentFilter)">void setDocumentFilter(DocumentFilter)</a> <br><em>(in <code>AbstractDocument</code>)</em> </td> <td>Set the document filter. </td> </tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#setDocument(javax.swing.text.Document)">void setDocument(Document)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getDocument()">Document getDocument()</a> <br><em>(in <code>JTextComponent</code>)</em> </td> <td>Set or get the document for a text component. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JTextField.html#createDefaultModel()">Document createDefaultModel()</a> <br><em>(in <code>JTextField</code>)</em> </td> <td>Override this method to create a custom document instead of the default <code>PlainDocument</code>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#addDocumentListener(javax.swing.event.DocumentListener)">void addDocumentListener(DocumentListener)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#removeDocumentListener(javax.swing.event.DocumentListener)">void removeDocumentListener(DocumentListener)</a> <br><em>(in <code>Document</code>)</em> </td> <td>Add or remove a document listener to a document. See <a href="generaltext.html#doclisteners"> Listening for Changes on a Document</a>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#addUndoableEditListener(javax.swing.event.UndoableEditListener)">void addUndoableEditListener(UndoableEditListener)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#removeUndoableEditListener(javax.swing.event.UndoableEditListener)">void removeUndoableEditListener(UndoableEditlistener)</a> <br><em>(in <code>Document</code>)</em> </td> <td>Add or remove an undoable edit listener to a document. Undoable edit listeners are used in <a href="generaltext.html#undo">Implementing Undo and Redo</a>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#getLength()">int getLength()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#getStartPosition()">Position getStartPosition()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#getEndPosition()">Position getEndPosition()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#getText(int, int)">String getText(int, int)</a> <br><em>(in <code>Document</code>)</em> </td> <td><code>Document</code> methods that return useful information about the document. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#getProperty(java.lang.Object)">Object getProperty(Object)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Document.html#putProperty(java.lang.Object, java.lang.Object)">void putProperty(Object, Object)</a> <br><em>(in <code>Document</code>)</em> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html#setDocumentProperties(java.util.Dictionary)">void setDocumentProperties(Dictionary)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html#getDocumentProperties()">Dictionary getDocumentProperties()</a> <br><em>(in <code>AbstractDocument</code>)</em> </td> <td>A <code>Document</code> maintains a set of properties that you can manipulate with these methods. </td> </tr></table><p><table border=1><caption><a name="carrots">Manipulating Carets and Selection Highlighters</a><br><em>The methods in this table are defined in the <code>JTextComponent</code> class.</em></caption><tr><th>Interface, Class, or Method</th><th>Description</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Caret.html">Caret</a> </td> <td>An interface that defines the API for objects that represent an insertion point within documents. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/DefaultCaret.html">DefaultCaret</a> </td> <td>The default caret used by all text components. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#setCaret(javax.swing.text.Caret)">void setCaret(Caret)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getCaret()">Caret getCaret()</a> </td> <td>Set or get the caret object used by a text component. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#setCaretColor(java.awt.Color)">void setCaretColor(Color)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getCaretColor()">Color getCaretColor()</a> </td> <td>Set or get the color of the caret. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#setCaretPosition(int)">void setCaretPosition(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#moveCaretPosition(int)">void moveCaretPosition(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getCaretPosition()">int getCaretPosition()</a> </td> <td>Set or get the current position of the caret within the document. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#addCaretListener(javax.swing.event.CaretListener)">void addCaretListener(CaretListener)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#removeCaretListener(javax.swing.event.CaretListener)">void removeCaretListener(CaretListener)</a> </td> <td>Add or remove a caret listener to a text component. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/NavigationFilter.html">NavigationFilter</a> </td> <td>The superclass for all navigation filters. A navigation filter lets you modify caret changes that are about to occur for a text component. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#setNavigationFilter(javax.swing.text.NavigationFilter)">void setNavigationFilter(NavigationFilter)</a> </td> <td>Attach a navigation filter to a text component. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/Highlighter.html">Highlighter</a> </td> <td>An interface that defines the API for objects used to highlight the current selection. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/DefaultHighlighter.html">DefaultHighlighter</a> </td> <td>The default highlighter used by all text components. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#setHighlighter(javax.swing.text.Highlighter)">void setHighlighter(Highlighter)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#getHighlighter()">Highlighter getHighlighter()</a> </td> <td>Set or get the highlighter used by a text component. </td> </tr></table><p><table border=1><caption><a name="io">Reading and Writing Text</a></caption><tr><th>Method</th><th>Description</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#read(java.io.Reader, java.lang.Object)">void read(Reader, Object)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#write(java.io.Writer)">void write(Writer)</a> <br><em>(in <code>JTextComponent</code>)</em> </td> <td>Read or write text. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/EditorKit.html#read(java.io.Reader, javax.swing.text.Document, int)">void read(Reader, Document, int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/EditorKit.html#read(java.io.InputStream, javax.swing.text.Document, int)">void read(InputStream, Document, int)</a> <br><em>(in <code>EditorKit</code>)</em> </td> <td>Read text from a stream into a document. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/EditorKit.html#write(java.io.Writer, javax.swing.text.Document, int, int)">void write(Writer, Document, int, int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/EditorKit.html#write(java.io.OutputStream, javax.swing.text.Document, int, int)">void write(OutputStream, Document, int, int)</a> <br><em>(in <code>EditorKit</code>)</em> </td> <td>Write text from a document to a stream. </td> </tr></table></blockquote> </blockquote> <div class=NavBit> <a target=_top href=generaltext.html>« Previous</a> • <a target=_top href=../TOC.html>Trail</a> • <a target=_top href=componentlist.html>Next »</a> </div> </div> <div id=Footer><div id=TagNotes> Problems with the examples? Try <a target="_blank" href=../../information/run-examples.html>Compiling and Running the Examples: FAQs</a>. <br> Complaints? Compliments? Suggestions? <a target="_blank" href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give us your feedback</a>.<br><br> <a target="_blank" href="../../information/copyright.html">Copyright</a> 1995-2006 Sun Microsystems, Inc. All rights reserved. <span id=Download></span></div> </div> <div class=PrintHeaders> <b>Previous page:</b> Text Component Features <br><b>Next page:</b> How to Use Various Components </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -