public class JTextPane extends JEditorPane
このコンポーネントは、文字レベル属性の並びから構成される段落をモデル化します。 各段落には、段落または文字の並びに設定される属性によってオーバーライドされないかぎり使用される、デフォルト属性を収めた論理書式が付属しています。 コンポーネントとイメージは、テキストの中に組み込むことができます。
警告: Swingはスレッドに対して安全ではありません。 詳細は、「Swing's Threading Policy」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースと互換ではなくなる予定です。 現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。 1.4以降、すべてのJavaBeans™用の長期間の格納サポートがjava.beansパッケージに追加されています。 XMLEncoderを参照してください。
StyledEditorKitJEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupportJTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBindingJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyHONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITSDEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEYlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| コンストラクタ | 説明 |
|---|---|
JTextPane() |
新しい
JTextPaneを作成します。 |
JTextPane(StyledDocument doc) |
指定されたドキュメント・モデルを使用して、新しい
JTextPaneを作成します。 |
| 修飾子と型 | メソッド | 説明 |
|---|---|---|
Style |
addStyle(String nm, Style parent) |
論理書式階層に新しい書式を追加します。
|
protected EditorKit |
createDefaultEditorKit() |
デフォルトで使う
EditorKitを作成します。 |
AttributeSet |
getCharacterAttributes() |
現在のキャレット位置で有効な文字属性がある場合はそれを取得します。ない場合は
nullを返します。 |
MutableAttributeSet |
getInputAttributes() |
ペインの入力属性を返します。
|
Style |
getLogicalStyle() |
現在のキャレット位置で表される段落に割り当てられている論理書式がある場合はそれを取得します。ない場合は
nullを返します。 |
AttributeSet |
getParagraphAttributes() |
キャレット位置で有効な現在の段落属性がある場合はそれを取得します。ない場合は
nullを返します。 |
Style |
getStyle(String nm) |
それまでに追加されていた
nullでない名前付き書式を取得します。 |
StyledDocument |
getStyledDocument() |
エディタに関連したモデルを取り出します。
|
protected StyledEditorKit |
getStyledEditorKit() |
エディタ・キットを返します。
|
String |
getUIClassID() |
UIのクラスIDを返します。
|
void |
insertComponent(Component c) |
現在選択されている内容の置換としてドキュメントにコンポーネントを挿入します。
|
void |
insertIcon(Icon g) |
現在選択されているコンテンツの置換後の内容としてドキュメントにアイコンを挿入します。
|
protected String |
paramString() |
この
JTextPaneの文字列表現を返します。 |
void |
removeStyle(String nm) |
それまでにドキュメントに追加されていた
nullでない名前付き書式を削除します。 |
void |
replaceSelection(String content) |
現在選択されているコンテンツを、渡された文字列が示す新しいコンテンツで置き換えます。
|
void |
setCharacterAttributes(AttributeSet attr, boolean replace) |
指定された属性を文字コンテンツに適用します。
|
void |
setDocument(Document doc) |
エディタをテキスト・ドキュメントに関連付けます。
|
void |
setEditorKit(EditorKit kit) |
コンテンツを処理するために現在インストールされているキットを設定します。
|
void |
setLogicalStyle(Style s) |
段落に使う論理書式を現在のキャレット位置に設定します。
|
void |
setParagraphAttributes(AttributeSet attr, boolean replace) |
指定された属性を段落に適用します。
|
void |
setStyledDocument(StyledDocument doc) |
エディタをテキスト・ドキュメントに関連付けます。
|
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setTextaddCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, writeaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic JTextPane()
JTextPaneを作成します。 StyledEditorKitの新しいインスタンスが生成および設定され、ドキュメント・モデルはnullに設定されます。 public JTextPane(StyledDocument doc)
JTextPaneを作成します。 javax.swing.text.StyledEditorKitの新しいインスタンスが生成および設定されます。 doc - ドキュメント・モデルpublic String getUIClassID()
getUIClassID、クラスJEditorPaneJComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)public void setDocument(Document doc)
StyledDocumentである必要があります。 setDocument、クラスJTextComponentdoc - 表示および編集するドキュメントIllegalArgumentException - docをこのテキスト・コンポーネントに必要な型のモデルであるStyledDocumentにナロー変換できない場合JTextComponent.getDocument()public void setStyledDocument(StyledDocument doc)
doc - 表示および編集するドキュメントpublic StyledDocument getStyledDocument()
public void replaceSelection(String content)
replaceSelection、クラスJEditorPanecontent - 選択範囲を置き換えるコンテンツpublic void insertComponent(Component c)
指定されるコンポーネントは、JTextPaneが使う実際のコンポーネントです。 コンポーネントは複数のコンテナの子になることはできないため、複数のテキスト・コンポーネントでモデルを共用する場合は、このメソッドを使わないでください。
コンポーネントは、Component.getAlignmentYによって返された値に従って、テキスト・ベースラインに相対的に配置されます。 Swingコンポーネントの場合、JComponent.setAlignmentYメソッドを使うと、この値を簡単に設定できます。 たとえば、値を0.75に設定すると、コンポーネントの75パーセントがベースラインの上に、25パーセントがベースラインの下になります。
c - 挿入されるコンポーネントpublic void insertIcon(Icon g)
g - 挿入されるアイコンIconpublic Style addStyle(String nm, Style parent)
nm - 書式の名前(名前付き書式のコレクション内で一意である必要がある)。 この名前は、書式に名前が付いていない場合はnullも可能だが、呼出し側は名前のない書式を名前で取得できないときに返される参照を管理する必要がある。 名前のない書式は、スタイル・ランで見られるような文字属性のオーバーライドなどで便利な場合がある。 parent - 親書式。 指定されていない属性がほかの書式で解釈処理される必要がない場合はnullも可。 Stylepublic void removeStyle(String nm)
nullでない名前付き書式を削除します。nm - 削除される書式の名前public Style getStyle(String nm)
nullでない名前付き書式を取得します。nm - 書式の名前Stylepublic void setLogicalStyle(Style s)
s - 段落に割り当てる論理書式。書式なしの場合はnullpublic Style getLogicalStyle()
nullを返します。Stylepublic AttributeSet getCharacterAttributes()
nullを返します。nullpublic void setCharacterAttributes(AttributeSet attr, boolean replace)
attr - 属性replace - trueの場合、既存の属性が最初に置き換えられるpublic AttributeSet getParagraphAttributes()
nullを返します。public void setParagraphAttributes(AttributeSet attr, boolean replace)
attr - null以外の属性replace - trueの場合、既存の属性が最初に置き換えられるpublic MutableAttributeSet getInputAttributes()
protected final StyledEditorKit getStyledEditorKit()
protected EditorKit createDefaultEditorKit()
EditorKitを作成します。 これを実装すると、javax.swing.text.StyledEditorKitが返されます。 createDefaultEditorKit、クラスJEditorPanepublic final void setEditorKit(EditorKit kit)
setEditorKit、クラスJEditorPanekit - 望ましいエディタ動作IllegalArgumentException - キットがStyledEditorKitではない場合JEditorPane.getEditorKit()protected String paramString()
JTextPaneの文字列表現を返します。 このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なります。 返される文字列は空の場合がありますが、nullにはなりません。 paramString、クラスJEditorPaneJTextPaneの文字列表現 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。