public class JTextPane extends JEditorPane
このコンポーネントは、文字レベル属性の並びから構成される段落をモデル化します。各段落には、段落または文字の並びに設定される属性によってオーバーライドされないかぎり使用される、デフォルト属性を収めた論理書式が付属しています。コンポーネントとイメージは、テキストの中に組み込むことができます。
警告: Swing はスレッドに対して安全ではありません。詳細は、「Swing's Threading Policy」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の格納や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。1.4 以降、すべての JavaBeansTM 用の長期間の格納サポートが 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_KEYaccessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_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, 2013, Oracle and/or its affiliates. All rights reserved.