try {
String url = "http://java.sun.com";
JEditorPane editorPane = new JEditorPane(url);
editorPane.setEditable(false);
editorPane.addListener(new MyListener());
} catch (IOException e) {
}
class MyListener implements Listener {
public void hyperlinkUpdate(Event evt) {
if (evt.getEventType() == Event.EventType.ACTIVATED) {
JEditorPane pane = (JEditorPane)evt.getSource();
try {
// Show the new page in the editor pane.
pane.setPage(evt.getURL());
} catch (IOException e) {
}
}
}
}