public class JEditorPane extends JTextComponent
该组件使用的EditorKit
实现完成其行为。它有效地变成正确的种是那种内容的文本编辑器了。编辑会在任何给定的时间的内容类型是由EditorKit
目前安装的确定。如果内容是设置一个新的URL,它的类型是用来确定应该用来加载内容的EditorKit
。
默认情况下,以下类型的内容是已知的:
DefaultEditorKit
生产包装的纯文本观的延伸。
javax.swing.text.html.HTMLEditorKit
提供HTML 3.2的支持。
javax.swing.text.rtf.RTFEditorKit
的富文本格式提供了有限的支持。
有几种方法来加载到这个组件的内容。
setText
方法可以用来从一个字符串初始化组件。在这种情况下,电流EditorKit
将被使用,和内容类型将是这类。read
方法可以用来从一个Reader
初始化组件。如果内容类型是HTML,相对引用(如图片一样)不能解决的除非<
<基地>
>标签使用或在
HTMLDocument
基本属性设置。在这种情况下,电流
EditorKit
将被使用,和内容类型将是这类。
基地>setPage
方法可用于从一个URL初始化组件。在这种情况下,内容类型将从URL确定,和注册EditorKit
,内容类型将设置。某些类型的内容可以通过生成超链接事件提供超链接支持。HTML EditorKit
如果JEditorPane
不可编辑生成链接事件(JEditorPane.setEditable(false);
被调用)。如果HTML框架嵌入在文件中,典型的反应将是改变当前文档的一部分。下面的代码片段是一个可能的链接实现侦听,对待HTML帧事件特别地显示任何其他激活超链接。
类实现hyperlinklistener {活跃 public void hyperlinkupdate(hyperlinkevent e){ 如果(如geteventtype() = = hyperlinkevent。事件类型。激活){ jeditorpane窗格=(jeditorpane)E. getsource(); 如果(E是htmlframehyperlinkevent){ htmlframehyperlinkevent EVT =(htmlframehyperlinkevent)E;这 doc =(这)getdocument()窗格; DOC。processhtmlframehyperlinkevent(EVT);其他 } { 尝试{ 窗格。setpage(E. geturl()); } catch(时间T){printstacktrace() T.; } } } } }
有关自定义文本/ HTML呈现请看W3C_LENGTH_UNITS
和HONOR_DISPLAY_PROPERTIES
在某些文档中的文化依赖的信息是通过一种机制,称为字符编码。字符编码是一个明确的定位一个字符集的成员(字母,汉字,数字,符号,或控制功能)的具体数字代码值。它表示该文件存储的方式。例如字符编码是ISO-8859-1,iso-8859-5,Shift JIS、EUC JP,和UTF-8。当文件被传递给一个用户代理(JEditorPane
)它是转换为文档字符集(iso-10646又名Unicode)。
有很多方法可以得到一个字符集映射发生JEditorPane
。
setContentType
方法建立。如果内容是由setPage
方法内容类型会根据URL的规范装载。它的文件是直接加载的,内容类型将有望在加载之前被设置。EditorKit
.read操作将被扔ChangedCharSetException
。读是一个新的阅读器,使用字符重新设置在ChangedCharSetException
指定的(这是一个IOException
)。警告: Swing是线程不安全的。更多信息见Swing's Threading Policy。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
Modifier and Type | Class and Description |
---|---|
protected class |
JEditorPane.AccessibleJEditorPane
这个类实现了对
JEditorPane 类可访问性支持。
|
protected class |
JEditorPane.AccessibleJEditorPaneHTML
这个类提供了支持
AccessibleHypertext ,是用在什么地方
EditorKit 安装在这个
JEditorPane 实例是
HTMLEditorKit 实例。
|
protected class |
JEditorPane.JEditorPaneAccessibleHypertextSupport
什么是返回
AccessibleJEditorPaneHTML.getAccessibleText 。
|
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static String |
HONOR_DISPLAY_PROPERTIES
用于指示从组件中的默认字体和前景颜色是否不在样式文本中指定的默认字体和前景颜色的客户端属性的键。
|
static String |
W3C_LENGTH_UNITS
主要用于指示是否
w3c compliant长度单位用于HTML客户端性能。
|
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 |
---|
JEditorPane()
创建一个新的
JEditorPane 。
|
JEditorPane(String url)
创建一个
JEditorPane 基于字符串的URL规范。
|
JEditorPane(String type, String text)
创建一个
JEditorPane 已初始化为给定的文本。
|
JEditorPane(URL initialPage)
创建一个
JEditorPane 基于输入指定的URL。
|
Modifier and Type | Method and Description |
---|---|
void |
addHyperlinkListener(HyperlinkListener listener)
添加一个超链接侦听器,用于通知任何更改,例如当选择和输入链接时。
|
protected EditorKit |
createDefaultEditorKit()
创建默认的编辑器工具(
PlainEditorKit )当构件是第一个被创造出来的。
|
static EditorKit |
createEditorKitForContentType(String type)
从编辑器包的默认注册表创建给定类型的处理程序。
|
void |
fireHyperlinkUpdate(HyperlinkEvent e)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
AccessibleContext |
getAccessibleContext()
获取与此相关的accessiblecontext jeditorpane。
|
String |
getContentType()
获取此编辑器当前要处理的内容的类型。
|
EditorKit |
getEditorKit()
获取当前安装的套件内容处理。
|
static String |
getEditorKitClassNameForContentType(String type)
返回当前注册
EditorKit 类类型的名称
type 。
|
EditorKit |
getEditorKitForContentType(String type)
获取编辑套件使用给定的内容类型。
|
HyperlinkListener[] |
getHyperlinkListeners()
返回所有的
HyperLinkListener s数组添加到这个jeditorpane与addhyperlinklistener()。
|
URL |
getPage()
获取当前正在显示的网址。
|
Dimension |
getPreferredSize()
返回的
JEditorPane 首选大小。
|
boolean |
getScrollableTracksViewportHeight()
如果一个视图中应力这
Scrollable 高度匹配视口高度返回true。
|
boolean |
getScrollableTracksViewportWidth()
如果一个视图中应力这
Scrollable 宽度到视口的宽度匹配,返回true。
|
protected InputStream |
getStream(URL page)
取一个流给定的URL,这是要由
setPage 方法加载。
|
String |
getText()
返回在这个编辑内容类型的术语在本
TextComponent 包含文本。
|
String |
getUIClassID()
获取用户界面的类标识。
|
protected String |
paramString()
返回该
JEditorPane 字符串表示形式。
|
void |
read(InputStream in, Object desc)
该方法将从流。
|
static void |
registerEditorKitForContentType(String type, String classname)
建立了
type 到
classname 默认绑定。
|
static void |
registerEditorKitForContentType(String type, String classname, ClassLoader loader)
建立了
type 到
classname 默认绑定。
|
void |
removeHyperlinkListener(HyperlinkListener listener)
移除一个超链接侦听器。
|
void |
replaceSelection(String content)
将当前选定的内容替换为由给定的字符串表示的新内容。
|
void |
scrollToReference(String reference)
滚动视图给出的参考位置(即返回值的方法
UL.getRef URL显示)。
|
void |
setContentType(String type)
设置此编辑器所处理的内容的类型。
|
void |
setEditorKit(EditorKit kit)
设置当前已安装的处理内容的工具包。
|
void |
setEditorKitForContentType(String type, EditorKit k)
直接设置给定类型的编辑器工具包。
|
void |
setPage(String url)
设置当前正在显示的网址。
|
void |
setPage(URL page)
设置当前正在显示的网址。
|
void |
setText(String t)
设置指定的内容,这
TextComponent 文本,它预计将在这个编辑器的内容类型的格式。
|
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, setDocument, 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 static final String W3C_LENGTH_UNITS
默认情况下不启用;使其设置客户端property
这个名字Boolean.TRUE
。
public static final String HONOR_DISPLAY_PROPERTIES
默认情况下,根据不同的外观和感觉;使其设置客户端property
这个名字Boolean.TRUE
。
public JEditorPane()
JEditorPane
。文档模型设置为
null
。
public JEditorPane(URL initialPage) throws IOException
JEditorPane
基于输入指定的URL。
initialPage
的URL
IOException
-如果URL
null
或无法访问
public JEditorPane(String url) throws IOException
JEditorPane
基于字符串的URL规范。
url
的URL
IOException
-如果URL
null
或无法访问
public JEditorPane(String type, String text)
JEditorPane
已初始化为给定的文本。这是一个方便的构造函数调用
setContentType
和
setText
方法。
type
-给定文本的MIME类型
text
-初始化文本;可以
null
NullPointerException
-如果
type
参数
null
public void addHyperlinkListener(HyperlinkListener listener)
listener
-听众
public void removeHyperlinkListener(HyperlinkListener listener)
listener
-听众
public HyperlinkListener[] getHyperlinkListeners()
HyperLinkListener
s数组添加到这个jeditorpane与addhyperlinklistener()。
HyperLinkListener
s说如果没有听众已添加一个空数组
public void fireHyperlinkUpdate(HyperlinkEvent e)
EditorKit
如果一个支持超链接的内容类型,目前正在积极和有联系的活动。侦听器列表最后处理到第一个。
e
-事件
EventListenerList
public void setPage(URL page) throws IOException
null
,然后创建一个新的默认文件和URL是读到它。如果URL包含参考位置,该位置将滚动通过调用
scrollToReference
方法。如果所需的URL是一个目前被显示,该文件将不加载。为了强制文档重新加载,必须清除文档的流描述属性。下面的代码展示了如何可以这样做:
= jeditorpane getdocument()文档;医生putproperty(document.streamdescriptionproperty,null);如果url地址是不是一个当前显示的
getStream
,方法是给子类的控制流提供。
这可能取决于负载的同步或异步的EditorKit
返回的文档。如果Document
类型是AbstractDocument
和有价值的AbstractDocument.getAsynchronousLoadPriority
,大于或等于零的返回,页面将装上使用一个单独的线程优先级。
如果文件被加载时,它会在被安装到一个电话setDocument
编辑现有的流,这势必会火属性更改事件。如果一个IOException
抛出部分加载的文档将被丢弃,既没有文件或页属性更改事件将被解雇。如果文件被加载和安装期将由UI然后将滚动如果需要建造它,然后页面属性更改事件将被解雇。
如果文件是异步加载,文件将被安装到立即调用setDocument
将消防文件属性更改事件的编辑,然后一个线程将被创建,开始做实际的加载。在这种情况下,页面属性更改事件不会直接由调用这个方法的调用,而是将在加载完成加载时被触发。它也将被发射的事件调度线程。由于调用线程不能扔在另螺纹失效事件的IOException
,页面属性更改事件将被解雇时,其他线程完成的负载是否是成功还是失败。
page
-网页的URL
IOException
-一
null
或无效页的规格,或从流中读取异常
getPage()
public void read(InputStream in, Object desc) throws IOException
HTMLEditorKit
型,和
desc
参数是一个
HTMLDocument
,然后调用
HTMLEditorKit
开始阅读。否则调用父类的方法加载模型为纯文本。
in
-从中读取流
desc
物体描述流
IOException
-由流被用来初始化抛出
JTextComponent.read(java.io.Reader, java.lang.Object)
,
JTextComponent.setDocument(javax.swing.text.Document)
protected InputStream getStream(URL page) throws IOException
setPage
方法加载。默认情况下,这个简单的打开了这个网址,并返回流。这可以重新做有益的事情像取流从缓存、监控流的进步,
这种方法有望有副作用创建内容类型,因此设置适当的EditorKit
用于载流。
如果流是一个HTTP连接,重定向将跟随和生成的URL将被设置为Document.StreamDescriptionProperty
这样相对URL可以妥善解决。
page
-网页的URL
IOException
public void scrollToReference(String reference)
UL.getRef
URL显示)。默认情况下,此方法只知道如何在一个HTML文档查找参考。实施要求的
scrollRectToVisible
方法完成实际滚动。如果滚动到参考位置是比其他类型的HTML文档的需要,这种方法应该重新实现。如果该组件是不可见的,这种方法将不会有任何效果。
reference
-指定位置滚动
public URL getPage()
null
,和相对的URL不会被解决。
null
如果没有
public void setPage(String url) throws IOException
url
-用于显示的URL
IOException
-一
null
或URL规范无效
public String getUIClassID()
getUIClassID
方法重写,继承类
JComponent
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected EditorKit createDefaultEditorKit()
PlainEditorKit
)当构件是第一个被创造出来的。
public EditorKit getEditorKit()
createDefaultEditorKit
来设置默认如果必要。
public final String getContentType()
EditorKit
关联的类型。
null
如果没有编辑工具集
public final void setContentType(String type)
getEditorKitForContentType
,然后
setEditorKit
如果编辑工具可以成功定位。这是最方便的方法,可以用来作为一种替代
setEditorKit
直接调用。
如果有一个字符集定义为内容类型规格参数,它将被用来加载时使用相关的EditorKit
输入流。例如,如果类型指定为text/html; charset=EUC-JP
内容将加载使用的EditorKit
注册提供给EditorKit
加载Unicode到文档text/html
和读者将使用EUC-JP
翻译为Unicode字符集。如果类型是不认可的,内容将使用EditorKit
注册为纯文本加载,text/plain
。
type
-非为内容的编辑支持
null
MIME类型
NullPointerException
-如果
type
参数
null
getContentType()
public void setEditorKit(EditorKit kit)
null
,安装了新的工具,并为它创建默认文档。一个
PropertyChange
事件(“editorkit”)总是被解雇时,
setEditorKit
叫做。
注:这已经改变模式的副作用,因为editorkit的来源是有特定类型的内容模型。这个方法会引起setdocument被调用者的名义保证内部状态的完整性。
kit
-所需的编辑行为
getEditorKit()
public EditorKit getEditorKitForContentType(String type)
EditorKit
注册为给定的类型,它将尝试创建的默认
EditorKit
登记
EditorKit
。如果失败,一个
PlainEditorKit
是在假设所有文本文件可以表示为纯文本。
这种方法可以重新使用一些其他类型的注册表。这可以重新实现,使用java激活框架,例如。
type
-非
null
内容类型
public void setEditorKitForContentType(String type, EditorKit k)
createEditorKitForContentType
安装处理一下内容类型和感觉偏差。
type
-非
null
内容类型
k
-编辑工具设置
public void replaceSelection(String content)
null
)这等于清除当前选择。替换文本将有当前定义的输入属性。如果组件是不可编辑的,嘟嘟和回报。
replaceSelection
方法重写,继承类
JTextComponent
content
-内容替代选择。这个值可以
null
public static EditorKit createEditorKitForContentType(String type)
ClassLoader
注册,这
ClassLoader
将用于负载的原型。如果没有注册
ClassLoader
,
Class.forName
将用于负载的原型。
一旦一个原型EditorKit
实例成功定位,这是克隆和克隆返回。
type
-内容类型
null
如果没有注册为给定类型
public static void registerEditorKitForContentType(String type, String classname)
type
到
classname
默认绑定。该类将在实际需要的时候动态加载,并且可以在尝试使用之前安全地更改,以避免加载不需要的类。原型
EditorKit
将满载
Class.forName
注册时用这个方法。
type
-非
null
内容类型
classname
的类加载后
public static void registerEditorKitForContentType(String type, String classname, ClassLoader loader)
type
到
classname
默认绑定。该类将被动态加载后,需要使用给定的
ClassLoader
,并且可以安全地改变之前尝试使用以避免不必要的类加载。
type
-非
null
内容类型
classname
的类加载后
loader
-
ClassLoader
使用加载的名字
public static String getEditorKitClassNameForContentType(String type)
EditorKit
类类型的名称
type
。
type
-非
null
内容类型
public Dimension getPreferredSize()
JEditorPane
首选大小。对于
JEditorPane
首选大小稍有改变从父类的首选尺寸。如果视口的大小变得小于组件的最小尺寸,用于跟踪的宽度或高度的可滚动的定义将假。默认的视口布局将首选大小,而不需在滚动跟踪。在这种情况下,正常的首选大小调整到最小尺寸。这使得像HTML表格缩到最小尺寸,然后被放在他们的最小尺寸,拒绝缩小下去。
getPreferredSize
方法重写,继承类
JComponent
Dimension
含首选大小
JComponent.setPreferredSize(java.awt.Dimension)
,
ComponentUI
public void setText(String t)
TextComponent
文本,它预计将在这个编辑器的内容类型的格式。例如,如果类型设置为
text/html
字符串应该是根据指定HTML。
这是实现删除当前文档的内容,并通过分析给定字符串使用当前EditorKit
取代他们。这给父类的语义,通过不改变的模型,同时支持目前设置该组件的内容类型。假设是,以前的内容是比较小的,而且以前的内容没有副作用。这两个假设都可以被侵犯,并导致不理想的结果。为了避免这种情况,建立一个新的文件,getEditorKit().createDefaultDocument()
,和用新的替换现有的Document
。你就放心上Document
不会有任何挥之不去的状态。
另一种加载这个组件串会创建一个StringReader和调用读取方法。在这种情况下,该模型将被替换后,它被初始化的字符串的内容。
setText
方法重写,继承类
JTextComponent
t
要设置新的文本;如果
null
旧的文本将被删除
getText()
public String getText()
TextComponent
包含文本。如果扔在试图检索文本是一个例外,
null
将返回。这是实现呼叫
JTextComponent.write
与
StringWriter
。
getText
方法重写,继承类
JTextComponent
setText(java.lang.String)
public boolean getScrollableTracksViewportWidth()
Scrollable
宽度到视口的宽度匹配,返回true。
getScrollableTracksViewportWidth
接口
Scrollable
getScrollableTracksViewportWidth
方法重写,继承类
JTextComponent
public boolean getScrollableTracksViewportHeight()
Scrollable
高度匹配视口高度返回true。
getScrollableTracksViewportHeight
接口
Scrollable
getScrollableTracksViewportHeight
方法重写,继承类
JTextComponent
Scrollable
的高度匹配自己的真,否则为假
protected String paramString()
JEditorPane
字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能会在实现过程中有所不同。返回的字符串是空的但可能不
null
。
paramString
方法重写,继承类
JTextComponent
JEditorPane
字符串表示形式
public AccessibleContext getAccessibleContext()
getAccessibleContext
接口
Accessible
getAccessibleContext
方法重写,继承类
JTextComponent
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.