How do I make hyperlinks work in an HTML page displayed in a JEditorPane?
Created May 4, 2012
Thomas Buck
Add a hyperlinkListner to your JEditorPane instance via addHyperlinkListener().
Define a hyperlinkUpdate() method as required when adding this listener. It's basically:
editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { try { if (e.getEventType == HyperlinkEventType.ACTIVATED) editorPane.setPage(e.getURL()); } catch (IOException e) { // handle as you like } }});