Class HtmlTest
java.lang.Object
HtmlTest
- public class HtmlTest
- extends java.lang.Object
This example illustrates how to insert HTML as a string into a JTextPane.
To do this, we create the text pane, set its content type to "text/html",
and set the text in the pane to the HTML content we want displayed.
This simple example hides a lot of detail related to the processing of HTML
documents in an efficient way. If all you need to do is a one-time
insertion of an HTML text string, then the method used here works fine. If
you need to update HTML content dynamically by inserting and deleting, you
should do so through the underlying HTMLDocument, which can be accessed with
JTextPane.getDocument.
For further information, see the Sun tutorial on Using
HTML in Swing Components. Documentation on HTMLDocument and related
HTML processing is in the JFC documentation for the package
javax.swing.text.html.
Method Summary |
static void |
main(java.lang.String[] args)
Do all work described in the class comment and display the result in a
scrollable frame. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HtmlTest
public HtmlTest()
main
public static void main(java.lang.String[] args)
- Do all work described in the class comment and display the result in a
scrollable frame.