public class JTextPane extends JEditorPane
此组件模型的段落是由字符级属性的运行组成的。每一段可以有一个合乎逻辑的方式连接到它包含默认属性使用属性如果不被设置在段落或字符运行。组件和图像可以嵌入在文本流中。
警告: Swing是线程不安全的。更多信息见Swing's Threading Policy。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
StyledEditorKit
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JTextPane()
创建一个新的
JTextPane 。
|
JTextPane(StyledDocument doc)
创建一个新的
JTextPane ,用指定的文档模型。
|
Modifier and Type | Method and Description |
---|---|
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()
返回用户界面的类标识。
|
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, setText
addCaretListener, 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, write
addAncestorListener, 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, update
add, 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, validateTree
action, 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, transferFocusUpCycle
public JTextPane()
JTextPane
。
StyledEditorKit
的新实例被创建和设置,以及文档模型设置为
null
。
public JTextPane(StyledDocument doc)
JTextPane
,用指定的文档模型。
javax.swing.text.StyledEditorKit
的新实例被创建和设置。
doc
-文档模型
public String getUIClassID()
getUIClassID
方法重写,继承类
JEditorPane
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public void setDocument(Document doc)
StyledDocument
。
setDocument
方法重写,继承类
JTextComponent
doc
-文档显示/编辑
IllegalArgumentException
-如果
doc
不能缩小到一个
StyledDocument
是所需类型的模型,这个文本组件
JTextComponent.getDocument()
public void setStyledDocument(StyledDocument doc)
doc
-文档显示/编辑
public StyledDocument getStyledDocument()
public void replaceSelection(String content)
replaceSelection
方法重写,继承类
JEditorPane
content
-内容替代选择
public void insertComponent(Component c)
该组件是由文本窗格使用的实际成分。由于组件不能是一个以上的容器的子容器,该方法不应该在模型由文本组件共享的情况下使用该方法。
元件放置相对于文本基线根据返回的值Component.getAlignmentY
,Swing组件的值可以方便的设置使用方法JComponent.setAlignmentY
。例如,设定值0.75
将导致组件百分之75是基线以上,和百分之25的分量要低于基线。
c
-插入元件
public void insertIcon(Icon g)
g
-图标插入
Icon
public Style addStyle(String nm, Style parent)
nm
-该样式的名称(必须命名风格的集合中是唯一的)。这个名字可能是
null
如果风格命名,但对方负责管理引用一位不愿透露姓名的风格不能取的名字返回。一位不愿透露姓名的风格可能像字符属性重写如风格运行发现是有用的。
parent
-父样式。这可能是
null
如果未指定的属性不需要一些其他的方式解决。
Style
public void removeStyle(String nm)
null
风格以前添加到文档。
nm
-风格的名字删除
public void setLogicalStyle(Style s)
s
-指定段落的逻辑风格,或
null
没有风格
public Style getLogicalStyle()
null
。
Style
public AttributeSet getCharacterAttributes()
null
。
null
public void setCharacterAttributes(AttributeSet attr, boolean replace)
attr
-属性
replace
-如果是真的,然后替换现有的属性
public AttributeSet getParagraphAttributes()
null
如果没有。
public void setParagraphAttributes(AttributeSet attr, boolean replace)
attr
-非
null
属性
replace
-如果属实,取代现有的属性
public MutableAttributeSet getInputAttributes()
protected final StyledEditorKit getStyledEditorKit()
protected EditorKit createDefaultEditorKit()
EditorKit
默认使用的。这是实现返回
javax.swing.text.StyledEditorKit
。
createDefaultEditorKit
方法重写,继承类
JEditorPane
public final void setEditorKit(EditorKit kit)
setEditorKit
方法重写,继承类
JEditorPane
kit
-所需的编辑行为
IllegalArgumentException
-如果不是
StyledEditorKit
试剂盒
JEditorPane.getEditorKit()
protected String paramString()
JTextPane
返回字符串表示。该方法旨在将只用于调试目的,其含量和返回的字符串格式不同的实现可能会有所不同。返回的字符串是空的但可能不
null
。
paramString
方法重写,继承类
JEditorPane
JTextPane
字符串表示形式
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.