APIdia Launch Partner
Top Fields Constructors Methods
sun.tools.jconsole

public Class HTMLPane

extends JEditorPane
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
javax.swing.*, javax.swing.event.*, javax.swing.text.*

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from javax.swing.JEditorPane:
HONOR_DISPLAY_PROPERTIESW3C_LENGTH_UNITS

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean
public synchronized void
setHasSelection(boolean b)

public void
setText(String text)

Overrides javax.swing.JEditorPane.setText.

Sets the text of this TextComponent to the specified content, which is expected to be in the format of the content type of this editor.

Inherited from javax.swing.JEditorPane:
addHyperlinkListenercreateDefaultEditorKitcreateEditorKitForContentTypefireHyperlinkUpdategetAccessibleContextgetContentTypegetEditorKitgetEditorKitClassNameForContentTypegetEditorKitForContentTypegetHyperlinkListenersgetPagegetPreferredSizegetScrollableTracksViewportHeightgetScrollableTracksViewportWidthgetStreamgetTextgetUIClassIDparamStringreadregisterEditorKitForContentTyperegisterEditorKitForContentTyperemoveHyperlinkListenerreplaceSelectionscrollToReferencesetContentTypesetEditorKitsetEditorKitForContentTypesetPagesetPage

Field Detail

hasSelectionback to summary
private boolean hasSelection

Constructor Detail

HTMLPaneback to summary
public HTMLPane()

Method Detail

getHasSelectionback to summary
public synchronized boolean getHasSelection()
setHasSelectionback to summary
public synchronized void setHasSelection(boolean b)
setTextback to summary
public void setText(String text)

Overrides javax.swing.JEditorPane.setText.

Doc from javax.swing.JEditorPane.setText.

Sets the text of this TextComponent to the specified content, which is expected to be in the format of the content type of this editor. For example, if the type is set to text/html the string should be specified in terms of HTML.

This is implemented to remove the contents of the current document, and replace them by parsing the given string using the current EditorKit. This gives the semantics of the superclass by not changing out the model, while supporting the content type currently set on this component. The assumption is that the previous content is relatively small, and that the previous content doesn't have side effects. Both of those assumptions can be violated and cause undesirable results. To avoid this, create a new document, getEditorKit().createDefaultDocument(), and replace the existing Document with the new one. You are then assured the previous Document won't have any lingering state.

  1. Leaving the existing model in place means that the old view will be torn down, and a new view created, where replacing the document would avoid the tear down of the old view.
  2. Some formats (such as HTML) can install things into the document that can influence future contents. HTML can have style information embedded that would influence the next content installed unexpectedly.

An alternative way to load this component with a string would be to create a StringReader and call the read method. In this case the model would be replaced after it was initialized with the contents of the string.