public class HTMLEditorKit extends StyledEditorKit implements Accessible
HTML EditorKitはいくつかの目標を持って提供されており、これはHTMLをモデル化する手法に反映されています。 そうした目標が、クラスの設計に実質的な影響を与えています。
HTMLのモデル化は、HTMLDocument
クラスで提供されています。 HTMLのモデル化については、そのドキュメントに詳しく記載されています。 編集のサポートは、主にtextパッケージで提供されます。
HTMLFactory
クラスによって提供されます。 ビューのセットを変更するには、HTMLFactoryをサブクラス化または置き換えた上で、getViewFactoryメソッドを実装し直して別のファクトリを返すようにします。
JEditorPane.setPage
を使ってロードする場合に非同期でロードされるドキュメントを生成します。 これは、ドキュメントのプロパティによって制御されます。 createDefaultDocument
メソッドをオーバーライドすれば、プロパティを変更できます。 作業のバッチ処理は、HTMLDocument.HTMLReader
クラスによって行われます。 実際の作業は、textパッケージ内のDefaultStyledDocument
およびAbstractDocument
クラスによって行われます。
この機能のサポートは、StyleSheet
クラスによって提供されます。 HTMLの表現は、EditorKitのStyleSheetプロパティの設定によって、自由に変えることができます。
修飾子と型 | クラス | 説明 |
---|---|---|
static class |
HTMLEditorKit.HTMLFactory |
HTML用のビューを作成するファクトリです。
|
static class |
HTMLEditorKit.HTMLTextAction |
HTMLを既存のドキュメントに挿入するのに便利ないくつかの簡易メソッドを提供するabstractアクションです。
|
static class |
HTMLEditorKit.InsertHTMLTextAction |
InsertHTMLTextActionは、既存のHTMLドキュメントに任意のHTML文字列を挿入するために使用できます。
|
static class |
HTMLEditorKit.LinkController |
関連付けられたコンポーネントを監視し、必要に応じてその上でハイパーリンク・イベントを発生させるクラスです。
|
static class |
HTMLEditorKit.Parser |
パーサーがサポートするインタフェースです。
|
static class |
HTMLEditorKit.ParserCallback |
構文解析の結果が、これらのコールバック・メソッドを呼び出します。
|
StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineAction
DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction
修飾子と型 | フィールド | 説明 |
---|---|---|
static String |
BOLD_ACTION |
ボールド処理識別子です。
|
static String |
COLOR_ACTION |
色選択処理識別子です。色は引数として渡されます。
|
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 |
段落の右インデント処理識別子です。
|
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction
コンストラクタ | 説明 |
---|---|
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) |
このタイプのコンテンツ・ハンドラに適した形式で、ドキュメントからストリームへコンテンツを書き込みます。
|
getCharacterAttributeRun
createCaret, read, write
public static final String DEFAULT_CSS
public static final String FONT_CHANGE_SMALLER
public static final String LOGICAL_STYLE_ACTION
public HTMLEditorKit()
public String getContentType()
text/html
タイプをサポートします。 getContentType
、クラスDefaultEditorKit
public ViewFactory getViewFactory()
getViewFactory
、クラスStyledEditorKit
public Document createDefaultDocument()
createDefaultDocument
、クラスStyledEditorKit
public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
doc
がHTMLDocumentのインスタンスである場合は、HTML 3.2テキストが読み取られます。 空でないドキュメントへのHTMLの挿入は、body要素の内側にする必要があります。本文に挿入しない場合、例外がスローされます。 空でないドキュメントへの挿入時は、bodyの外側のタグ(head、title)がすべて削除されます。 read
、クラスDefaultEditorKit
in
- 読込み元のストリームdoc
- 挿入先pos
- コンテンツを配置するドキュメント内の位置IOException
- 入出力エラーが発生した場合BadLocationException
- posがドキュメント内の無効な位置を表す場合RuntimeException
- posが無効な場合(結果的にBadLocationExceptionになる)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.JoinNextDirectionの方向を持つElementSpec.StartTagTypeタグの数insertTag
- ドキュメントへの挿入を開始する最初のタグRuntimeException
- posが無効な場合(結果的にBadLocationExceptionになる)BadLocationException
IOException
public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
write
、クラスDefaultEditorKit
out
- 書込み先のストリームdoc
- 書込み元pos
- コンテンツを取得するドキュメント内の位置len
- 書き出す量IOException
- 入出力エラーが発生した場合BadLocationException
- posがドキュメント内の無効な位置を表す場合public void install(JEditorPane c)
install
、クラスStyledEditorKit
c
- JEditorPanepublic void deinstall(JEditorPane c)
deinstall
、クラスStyledEditorKit
c
- JEditorPanepublic void setStyleSheet(StyleSheet s)
public StyleSheet getStyleSheet()
public Action[] getActions()
getActions
、クラスStyledEditorKit
protected void createInputAttributes(Element element, MutableAttributeSet set)
element
のAttributeSet内のキーと値のペアをset
にコピーします。 このメソッドは、コンポーネント、アイコン、要素名の各属性はコピーしません。 サブクラスでは、どの属性をコピーしてどの属性をコピーしないかを変更することもできます。 ただし、最初にset
内のすべての属性を必ず削除してください。 このメソッドは、キャレットが別の位置に移動するたびに呼び出されます。
createInputAttributes
、クラスStyledEditorKit
public MutableAttributeSet getInputAttributes()
getInputAttributes
、クラスStyledEditorKit
public 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()
, FormSubmitEvent
public Object clone()
clone
、クラスStyledEditorKit
Cloneable
protected HTMLEditorKit.Parser getParser()
public AccessibleContext getAccessibleContext()
getAccessibleContext
、インタフェースAccessible
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。