JTextPane is a powerful component that allows text with various fonts, colors, and styles to be intermixed and displayed with images and other components. Working with JTextPane is fairly complex and tedious because each piece of text must have attributes created and attached. JEditorPane is a similar class, but it includes an "editor kit" capable of interpreting and displaying HTML and RTF documents.

In the example, a JTextField component is defined at the top of the window for the user to supply a URL. When the Return key is pressed, an ActionEvent is broadcast. The ActionListener object retrieves the user input and passes it to the JEditorPane object. [That object was set-up as a static data member because the anonymous ActionListener class defined in main() could not access a local object reference.] The JEditorPane component takes it from there.

[Reference: Topley, pp734,759-785]