Hyperlinks in JEditorPane

JEditorPane renders HTML fairly well when you
pass a URL to its setPage() method.

However, to make it a browser you have to add a HyperlinkListener.

JEditorPane
+ addHyperlinkListener(HyperlinkListener)
+ setPage(URL)
Interface
HyperlinkListener
+ hyperlinkUpdate(HyperlinkEvent)
HyperlinkEvent
+ getDescription() : String
+ getEventType() : int
+ getURL() : URL

public class HelpBrowser {
    private JEditorPane htmlPane;
    private JLabel      statusBar;

    private HelpBrowser(Frame parent) {

        htmlPane = new JEditorPane();

        htmlPane.addHyperlinkListener(new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent event) {
                doHyperlink(event);
            }
        });
    }

    private void doHyperlink(final HyperlinkEvent event) {
        HyperlinkEvent.EventType type = event.getEventType();

        if (type == LINK_ENTERED) {
            statusBar.setText(event.getURL().toString());
            return;
        }
        if (type == LINK_EXITED) {
            statusBar.setText(null);
            return;
        }
        setPage(event.getURL(), ADD_TO_HISTORY);
    }
}