public class

HTMLPane

extends JEditorPane
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ javax.swing.JComponent
         ↳ javax.swing.text.JTextComponent
           ↳ javax.swing.JEditorPane
             ↳ sun.tools.jconsole.HTMLPane

Summary

[Expand]
Inherited Constants
From class javax.swing.JEditorPane
From class javax.swing.text.JTextComponent
From class javax.swing.JComponent
From class java.awt.Component
From interface java.awt.image.ImageObserver
[Expand]
Inherited Fields
From class javax.swing.JComponent
Public Constructors
HTMLPane()
Public Methods
synchronized boolean getHasSelection()
synchronized void setHasSelection(boolean b)
void setText(String text)
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.
[Expand]
Inherited Methods
From class javax.swing.JEditorPane
From class javax.swing.text.JTextComponent
From class javax.swing.JComponent
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface javax.accessibility.Accessible
From interface javax.swing.Scrollable

Public Constructors

public HTMLPane ()

Public Methods

public synchronized boolean getHasSelection ()

public synchronized void setHasSelection (boolean b)

public void setText (String text)

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.

This method is thread safe, although most Swing methods are not. Please see How to Use Threads for more information.

Parameters
text the new text to be set; if null the old text will be deleted