|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
public class PlainDocument
維護無任何字元屬性的普通文檔。此文檔的預設元素結構是文本中的行的映射。由 getDefaultRootElement 返回的 Element 是行的映射,且每個子元素表示一行。此模型不維護任何字元級屬性,但每行都可以用一個任意的屬性集來標記。使用預設的根元素可以快速執行從行到偏移量和從偏移量到行的轉換。由編輯觸發的 DocumentEvent 的結構資訊將指示行結構的更改。
預設的內容存儲管理是通過間隙緩衝區實作 (GapContent) 執行的。如果編輯是連續的或集群化的(正如常見的那樣),此操作支持對大型文檔的高效合理編輯。
警告:此類別的已序列化物件與以後的 Swing 版本不相容。當前的序列化支持適用於短期存儲或運行相同 Swing 版本的應用程序之間的 RMI。從 1.4 版本開始,已在 java.beans 套件中添加了支持所有 JavaBeansTM 長期存儲的功能。請參見 XMLEncoder。
Document,
AbstractDocument| 巢狀類別摘要 |
|---|
| 欄位摘要 | |
|---|---|
static String |
lineLimitAttribute
指定行的最大長度的屬性名稱(如果有最大長度)。 |
static String |
tabSizeAttribute
指定內容中包含的製表符大小的屬性名稱。 |
| 從類別 javax.swing.text.AbstractDocument 繼承的欄位 |
|---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
| 從介面 javax.swing.text.Document 繼承的欄位 |
|---|
StreamDescriptionProperty, TitleProperty |
| 建構子摘要 | |
|---|---|
PlainDocument()
建構一個純文本文檔。 |
|
PlainDocument(AbstractDocument.Content c)
建構一個純文本文檔。 |
|
| 方法摘要 | |
|---|---|
protected AbstractDocument.AbstractElement |
createDefaultRoot()
創建用於表示預設文檔結構的根元素。 |
Element |
getDefaultRootElement()
獲取文檔模型的預設根元素。 |
Element |
getParagraphElement(int pos)
獲取包含給定位置的段落元素。 |
void |
insertString(int offs,
String str,
AttributeSet a)
向文檔中插入某些內容。 |
protected void |
insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
AttributeSet attr)
隨文本插入更新文檔結構。 |
protected void |
removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
隨文本的移除更新任何文檔結構。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 欄位詳細資訊 |
|---|
public static final String tabSizeAttribute
public static final String lineLimitAttribute
| 建構子詳細資訊 |
|---|
public PlainDocument()
GapContent 的預設模型。
public PlainDocument(AbstractDocument.Content c)
c - 內容容器| 方法詳細資訊 |
|---|
public void insertString(int offs,
String str,
AttributeSet a)
throws BadLocationException
雖然大多數 Swing 方法不是執行緒安全的,但此方法是執行緒安全的。有關更多資訊,請參閱 How to Use Threads。
Document 中的 insertStringAbstractDocument 中的 insertStringoffs - 起始偏移量,該值 >= 0str - 要插入的字元串;null/空字元串不執行任何操作a - 插入內容的屬性
BadLocationException - 如果給定的插入位置不是文檔中的有效位置Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet)public Element getDefaultRootElement()
Document 中的 getDefaultRootElementAbstractDocument 中的 getDefaultRootElementDocument.getDefaultRootElement()protected AbstractDocument.AbstractElement createDefaultRoot()
public Element getParagraphElement(int pos)
AbstractDocument 中的 getParagraphElementpos - 起始偏移量,該值 >= 0
protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
AttributeSet attr)
AbstractDocument 中的 insertUpdatechng - 描述編輯的更改事件attr - 插入文本的屬性集protected void removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
AbstractDocument 中的 removeUpdatechng - 描述編輯的更改事件
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。