|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
javax.swing.text.StyledEditorKit
javax.swing.text.html.HTMLEditorKit
public class HTMLEditorKit
Swing JEditorPane 文本元件通過稱為 EditorKit 的外掛程式機制來支持不同種類別的內容。因為 HTML 是很串流行的內容格式,因此預設提供了某種支持。此類別提供了 HTML version 3.2(帶有某些擴展)的預設支持,並正在向 version 4.0 遷移。不支持 <applet> 標記,但為 <object> 標記提供了某種支持。
提供 HTML EditorKit 有幾個目的,這些目的影響了 HTML 的建模方式。並從基本方法上影響了其設計。
HTMLDocument 類別提供了 HTML 的建模。其文檔描述了建模 HTML 的細節。編輯支持主要不利用 text 套件。
HTMLFactory 類別提供。可以輕鬆地更改此方法,方法是創建 HTMLFactory 的子類別或替換 HTMLFactory 類別,並重新實作 getViewFactory 方法以返回替代的處理器。
JEditorPane.setPage 來載入)。這由文檔的一個屬性來控制。這可以通過覆寫 createDefaultDocument 方法來更改。批處理工作由 HTMLDocument.HTMLReader 類別完成。實際的工作由 text 套件中的 DefaultStyledDocument 和 AbstractDocument 類別完成。
StyleSheet 類別提供了這種支持。通過設置 EditorKit 上的 StyleSheet 屬性,可以對 HTML 的表示產生很大影響。
| 巢狀類別摘要 | |
|---|---|
static class |
HTMLEditorKit.HTMLFactory
用於建構 HTML 視圖的處理器。 |
static class |
HTMLEditorKit.HTMLTextAction
提供某些便捷方法的抽象 Action,這些便捷方法對於將 HTML 插入現有文檔可能很有用。 |
static class |
HTMLEditorKit.InsertHTMLTextAction
InsertHTMLTextAction 可用於將任意 HTML 字元串插入現有 HTML 文檔。 |
static class |
HTMLEditorKit.LinkController
此類別用於觀察關聯元件並在適當的時候觸發該元件上的超連接事件。 |
static class |
HTMLEditorKit.Parser
解析器要支持的介面。 |
static class |
HTMLEditorKit.ParserCallback
解析結果驅動這些回調方法。 |
| 欄位摘要 | |
|---|---|
static String |
BOLD_ACTION
粗體動作標識符 |
static String |
COLOR_ACTION
Color 選擇動作標識符(顏色作為參數傳遞) |
static String |
DEFAULT_CSS
用於設置標記視圖的預設級聯樣式表 (Cascading Style Sheet) 檔案。 |
static String |
FONT_CHANGE_BIGGER
字體大小增大到下一個值的動作標識符 |
static String |
FONT_CHANGE_SMALLER
字體大小減小到下一個值的動作標識符 |
static String |
IMG_ALIGN_BOTTOM
將圖像底部對齊。 |
static String |
IMG_ALIGN_MIDDLE
將圖像居中對齊。 |
static String |
IMG_ALIGN_TOP
將圖像頂部對齊。 |
static String |
IMG_BORDER
將圖像對齊到邊框。 |
static String |
ITALIC_ACTION
斜體動作標識符 |
static String |
LOGICAL_STYLE_ACTION
邏輯樣式選擇動作標識符(邏輯樣式作為參數傳遞) |
static String |
PARA_INDENT_LEFT
段落左縮進動作標識符 |
static String |
PARA_INDENT_RIGHT
段落右縮進動作標識符 |
| 建構子摘要 | |
|---|---|
HTMLEditorKit()
建構 HTMLEditorKit,創建 StyleContext,並載入樣式表。 |
|
| 方法摘要 | |
|---|---|
Object |
clone()
創建編輯器工具套件的一個副本。 |
Document |
createDefaultDocument()
創建一個適合此編輯器型別的未初始化文本存儲模型。 |
protected void |
createInputAttributes(Element element,
MutableAttributeSet set)
將 element 的 AttributeSet 鍵/值複製到 set 中。 |
void |
deinstall(JEditorPane c)
工具套件從 JEditorPane 移除時調用。 |
AccessibleContext |
getAccessibleContext()
返回與此編輯器工具套件關聯的 AccessibleContext。 |
Action[] |
getActions()
獲取編輯器的命令列表。 |
String |
getContentType()
獲取此工具套件支持的 MIME 型別的資料。 |
Cursor |
getDefaultCursor()
返回預設鼠標。 |
MutableAttributeSet |
getInputAttributes()
獲取該樣式編輯動作的輸入屬性。 |
Cursor |
getLinkCursor()
返回要在超連接上使用的鼠標。 |
protected HTMLEditorKit.Parser |
getParser()
獲取要用於讀取 HTML 串流的解析器。 |
StyleSheet |
getStyleSheet()
獲取當前正用於呈現 HTML 元素的樣式集。 |
ViewFactory |
getViewFactory()
獲取一個適合供由此套件所產生的任何模型來產生視圖的處理器。 |
void |
insertHTML(HTMLDocument doc,
int offset,
String html,
int popDepth,
int pushDepth,
HTML.Tag insertTag)
將 HTML 插入現有文檔。 |
void |
install(JEditorPane c)
將工具套件安裝到 JEditorPane 中時調用。 |
boolean |
isAutoFormSubmission()
指示是否自動處理 html 表單提交,或只是觸發 FormSubmitEvent。 |
void |
read(Reader in,
Document doc,
int pos)
插入來自給定串流的內容。 |
void |
setAutoFormSubmission(boolean isAuto)
指定是否自動處理 html 表單提交,或只是觸發 FormSubmitEvent。 |
void |
setDefaultCursor(Cursor cursor)
設置預設鼠標。 |
void |
setLinkCursor(Cursor cursor)
設置要在連接上使用的鼠標。 |
void |
setStyleSheet(StyleSheet s)
設置要用於呈現各種 HTML 元素的樣式集。 |
void |
write(Writer out,
Document doc,
int pos,
int len)
以適合此類別內容處理程序的格式,將文檔中的內容寫入給定串流。 |
| 從類別 javax.swing.text.StyledEditorKit 繼承的方法 |
|---|
getCharacterAttributeRun |
| 從類別 javax.swing.text.DefaultEditorKit 繼承的方法 |
|---|
createCaret, read, write |
| 從類別 java.lang.Object 繼承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 欄位詳細資訊 |
|---|
public static final String DEFAULT_CSS
public static final String BOLD_ACTION
public static final String ITALIC_ACTION
public static final String PARA_INDENT_LEFT
public static final String PARA_INDENT_RIGHT
public static final String FONT_CHANGE_BIGGER
public static final String FONT_CHANGE_SMALLER
public static final String COLOR_ACTION
public static final String LOGICAL_STYLE_ACTION
public static final String IMG_ALIGN_TOP
public static final String IMG_ALIGN_MIDDLE
public static final String IMG_ALIGN_BOTTOM
public static final String IMG_BORDER
| 建構子詳細資訊 |
|---|
public HTMLEditorKit()
| 方法詳細資訊 |
|---|
public String getContentType()
text/html 型別。
DefaultEditorKit 中的 getContentTypepublic ViewFactory getViewFactory()
StyledEditorKit 中的 getViewFactorypublic Document createDefaultDocument()
StyledEditorKit 中的 createDefaultDocument
public void read(Reader in,
Document doc,
int pos)
throws IOException,
BadLocationException
doc 是 HTMLDocument 的一個實例,則這將讀取 HTML 3.2 文本。將 HTML 插入非空(null)文檔時必須插入到正文 Element 的內部,如果未插入正文中,則拋出一個異常。當插入非空(null)文檔時,正文外部的所有標記(頭、標題)將被刪除。
DefaultEditorKit 中的 readin - 要從其讀取的串流doc - 插入的目標pos - 在文檔中放置內容的位置
IOException - 如果發生任何 I/O 錯誤
BadLocationException - 如果 pos 代表文檔中的無效位置
RuntimeException - (最終將為 BadLocationException)如果 pos 無效
public void insertHTML(HTMLDocument doc,
int offset,
String html,
int popDepth,
int pushDepth,
HTML.Tag insertTag)
throws BadLocationException,
IOException
doc - 內容將要插入的文檔offset - HTML 插入位置的偏移量popDepth - 插入前要產生的 ElementSpec.EndTagTypes 的數量pushDepth - 插入前但產生結束標記之後,應該產生的 ElementSpec.StartTagTypes 的數量(它具有 ElementSpec.JoinNextDirection 方向)insertTag - 開始插入文檔的首個標記
RuntimeException - (最終將為 BadLocationException)如果 pos 無效
BadLocationException
IOException
public void write(Writer out,
Document doc,
int pos,
int len)
throws IOException,
BadLocationException
DefaultEditorKit 中的 writeout - 要寫入的串流doc - 寫入的源pos - 在文檔中獲取內容的位置len - 寫出量
IOException - 如果發生任何 I/O 錯誤
BadLocationException - 如果 pos 代表文檔中的無效位置public void install(JEditorPane c)
StyledEditorKit 中的 installc - JEditorPanepublic void deinstall(JEditorPane c)
StyledEditorKit 中的 deinstallc - JEditorPanepublic void setStyleSheet(StyleSheet s)
public StyleSheet getStyleSheet()
public Action[] getActions()
StyledEditorKit 中的 getActions
protected void createInputAttributes(Element element,
MutableAttributeSet set)
element 的 AttributeSet 鍵/值複製到 set 中。此操作不複製元件、圖標或者元素名稱屬性。子類別可能希望修改此處要複製什麼,不複製什麼。確保首先移除 set 中的所有屬性。這在插入符移到一個不同位置時調用。
StyledEditorKit 中的 createInputAttributespublic MutableAttributeSet getInputAttributes()
StyledEditorKit 中的 getInputAttributespublic void setDefaultCursor(Cursor cursor)
public Cursor getDefaultCursor()
public void setLinkCursor(Cursor cursor)
public Cursor getLinkCursor()
public boolean isAutoFormSubmission()
FormSubmitEvent。
setAutoFormSubmission(boolean)public void setAutoFormSubmission(boolean isAuto)
FormSubmitEvent。預設情況下設置為 true。
isAutoFormSubmission,
FormSubmitEventpublic Object clone()
StyledEditorKit 中的 cloneCloneableprotected HTMLEditorKit.Parser getParser()
public AccessibleContext getAccessibleContext()
Accessible 中的 getAccessibleContext
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。