|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
public class DefaultStyledDocument
能夠以類似富文本格式 (Rich Text Format) 的方式對其字元和段落樣式進行標記的文檔。此文檔的元素結構表示樣式在運行時的相互參考。這些樣式運行被映射到段落元素結構(也有可能以其他結構形式駐留)。樣式運行在段落邊界處中斷,原因是段落邊界被指派了邏輯樣式。
警告:此類別的已序列化物件與以後的 Swing 版本不相容。當前序列化支持適用於短期存儲或運行相同 Swing 版本的應用程序之間的 RMI。從 1.4 版本開始,已在 java.beans 套件中添加了支持所有 JavaBeansTM 長期存儲的功能。請參見 XMLEncoder。
Document,
AbstractDocument| 巢狀類別摘要 | |
|---|---|
static class |
DefaultStyledDocument.AttributeUndoableEdit
用於記住 AttributeSet 對 Element 更改的一個 UndoableEdit。 |
class |
DefaultStyledDocument.ElementBuffer
管理對元素層次結構更改的類別。 |
static class |
DefaultStyledDocument.ElementSpec
建構元素的規範。 |
protected class |
DefaultStyledDocument.SectionElement
文檔的預設根元素... 與所包含的段落/行對應。 |
| 欄位摘要 | |
|---|---|
protected DefaultStyledDocument.ElementBuffer |
buffer
|
static int |
BUFFER_SIZE_DEFAULT
初始內容緩衝區的預設大小。 |
| 從類別 javax.swing.text.AbstractDocument 繼承的欄位 |
|---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
| 從介面 javax.swing.text.Document 繼承的欄位 |
|---|
StreamDescriptionProperty, TitleProperty |
| 建構子摘要 | |
|---|---|
DefaultStyledDocument()
建構預設的樣式化文檔。 |
|
DefaultStyledDocument(AbstractDocument.Content c,
StyleContext styles)
建構樣式化文檔。 |
|
DefaultStyledDocument(StyleContext styles)
建構具有預設的內容存儲實作和一組共享樣式的樣式化文檔。 |
|
| 方法摘要 | |
|---|---|
void |
addDocumentListener(DocumentListener listener)
添加負責通知任何更改的文檔偵聽器。 |
Style |
addStyle(String nm,
Style parent)
向邏輯樣式層次結構中添加新樣式。 |
protected void |
create(DefaultStyledDocument.ElementSpec[] data)
初始化文檔,以反映給定元素結構(即由 getDefaultRootElement 方法報告的結構)。 |
protected AbstractDocument.AbstractElement |
createDefaultRoot()
創建用於代表預設文檔結構的根元素。 |
Color |
getBackground(AttributeSet attr)
從屬性集獲得背景顏色。 |
Element |
getCharacterElement(int pos)
獲得基於某個位置的字元元素。 |
Element |
getDefaultRootElement()
獲得預設的根元素。 |
Font |
getFont(AttributeSet attr)
從屬性集獲得字體。 |
Color |
getForeground(AttributeSet attr)
從屬性集獲得前景色。 |
Style |
getLogicalStyle(int p)
獲取表示給定位置處分派給段落的邏輯樣式。 |
Element |
getParagraphElement(int pos)
獲得位於偏移量 pos 的段落元素。 |
Style |
getStyle(String nm)
獲取以前添加的已命名的樣式。 |
Enumeration<?> |
getStyleNames()
獲取樣式名稱列表。 |
protected void |
insert(int offset,
DefaultStyledDocument.ElementSpec[] data)
批量插入新元素。 |
protected void |
insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
AttributeSet attr)
在文本插入後更新文檔結構。 |
void |
removeDocumentListener(DocumentListener listener)
移除文檔偵聽器。 |
void |
removeStyle(String nm)
移除以前添加到文檔中的已命名樣式。 |
protected void |
removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
在文本移除後更新文檔結構。 |
void |
setCharacterAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
為文檔某些部分設置屬性。 |
void |
setLogicalStyle(int pos,
Style s)
設置給定位置處用於段落的邏輯樣式。 |
void |
setParagraphAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
設置段落屬性。 |
protected void |
styleChanged(Style style)
此文檔樣式有任何改變時調用。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 從介面 javax.swing.text.Document 繼承的方法 |
|---|
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeUndoableEditListener, render |
| 欄位詳細資訊 |
|---|
public static final int BUFFER_SIZE_DEFAULT
protected DefaultStyledDocument.ElementBuffer buffer
| 建構子詳細資訊 |
|---|
public DefaultStyledDocument(AbstractDocument.Content c,
StyleContext styles)
c - 內容容器styles - 可跨文檔共享的資源和樣式定義public DefaultStyledDocument(StyleContext styles)
styles - 樣式public DefaultStyledDocument()
| 方法詳細資訊 |
|---|
public Element getDefaultRootElement()
Document 中的 getDefaultRootElementAbstractDocument 中的 getDefaultRootElementDocument.getDefaultRootElement()protected void create(DefaultStyledDocument.ElementSpec[] data)
getDefaultRootElement 方法報告的結構)。如果該文檔包含了任何資料,將首先移除這些資料。
protected void insert(int offset,
DefaultStyledDocument.ElementSpec[] data)
throws BadLocationException
雖然大多數 Swing 方法不是執行緒安全的,但此方法是執行緒安全的。有關更多資訊,請參閱 How to Use Threads。
offset - 起始偏移量,該偏移量 >= 0data - 元素資料
BadLocationException - 無效的起始偏移量
public Style addStyle(String nm,
Style parent)
StyledDocument 中的 addStylenm - 樣式的名稱(在命名樣式集合中必須是惟一的)。如果樣式未命名,則此名稱可能為 null,但是調用者要負責管理返回的參考,因為未命名的樣式不能通過其名稱獲取。未命名的樣式可以用於諸如字元屬性覆寫這樣的情況(例如在樣式運行中)。parent - 父樣式。如果未指定的屬性不需要以其他樣式解析,則此值可以為 null。
public void removeStyle(String nm)
StyledDocument 中的 removeStylenm - 要移除的樣式的名稱public Style getStyle(String nm)
StyledDocument 中的 getStylenm - 樣式名稱
public Enumeration<?> getStyleNames()
public void setLogicalStyle(int pos,
Style s)
雖然大多數 Swing 方法不是執行緒安全的,但此方法是執行緒安全的。有關更多資訊,請參閱 How to Use Threads。
StyledDocument 中的 setLogicalStylepos - 文檔開始處的偏移量,該偏移量 >= 0s - 要分派給段落的邏輯樣式,如果沒有,則為 nullpublic Style getLogicalStyle(int p)
StyledDocument 中的 getLogicalStylep - 要轉換為段落的位置和確定邏輯樣式要分派到的位置,該值 >= 0。這是文檔開始處的偏移量。
public void setCharacterAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
雖然大多數 Swing 方法不是執行緒安全的,但此方法是執行緒安全的。有關更多資訊,請參閱 How to Use Threads。
StyledDocument 中的 setCharacterAttributesoffset - 文檔中的偏移量,該偏移量 >= 0length - 長度,該長度 >= 0s - 屬性replace - 如果應在設置新屬性之前替換原來的屬性,則為 true
public void setParagraphAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
雖然大多數 Swing 方法不是執行緒安全的,但此方法是執行緒安全的。有關更多資訊,請參閱 How to Use Threads。
StyledDocument 中的 setParagraphAttributesoffset - 段落偏移量,該偏移量 >= 0length - 所影響的字元數,該字元數 >= 0s - 屬性replace - 確定是替換現有屬性還是合併現有屬性public Element getParagraphElement(int pos)
pos 的段落元素。一個段落至少要包含一個子 Element,它通常為葉元素。
StyledDocument 中的 getParagraphElementAbstractDocument 中的 getParagraphElementpos - 起始偏移量,該偏移量 >= 0
public Element getCharacterElement(int pos)
StyledDocument 中的 getCharacterElementpos - 文檔中的位置,該位置 >= 0
protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
AttributeSet attr)
AbstractDocument 中的 insertUpdatechng - 對文檔更改的描述attr - 屬性protected void removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
AbstractDocument 中的 removeUpdatechng - 對文檔更改的描述protected AbstractDocument.AbstractElement createDefaultRoot()
public Color getForeground(AttributeSet attr)
StyledDocument 中的 getForegroundattr - 屬性集
public Color getBackground(AttributeSet attr)
StyledDocument 中的 getBackgroundattr - 屬性集
public Font getFont(AttributeSet attr)
StyledDocument 中的 getFontattr - 屬性集
protected void styleChanged(Style style)
style - 已發生更改的樣式。public void addDocumentListener(DocumentListener listener)
Document 中的 addDocumentListenerAbstractDocument 中的 addDocumentListenerlistener - 偵聽器Document.addDocumentListener(javax.swing.event.DocumentListener)public void removeDocumentListener(DocumentListener listener)
Document 中的 removeDocumentListenerAbstractDocument 中的 removeDocumentListenerlistener - 偵聽器Document.removeDocumentListener(javax.swing.event.DocumentListener)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。