This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JEditorPane HTML Anchor Links Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JEditorPane HTML Anchor Links" Watch "JEditorPane HTML Anchor Links" New topic

JEditorPane HTML Anchor Links

David Reck
Ranch Hand

Joined: May 25, 2001
Posts: 37
I have loaded an HTML file in a JEditorPane as a systems online help. The file has some links that are anchors to places lower in the file. How do I make these links work. I have tried using a HyperlinkListener but am not having much luck getting it to work like anchors work in a browser.
Ranch Hand

Joined: Jun 21, 2001
Posts: 57
try out !!!
jEditorPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent hev) {
try {
if (hev.getEventType == HyperlinkEventType.ACTIVATED)
catch (IOException e) {
// Exceptions thrown...............

Ranch Hand

Joined: Jun 21, 2001
Posts: 57

Add a hyperlinkListner to your JEditorPane via addHyperlinkListener().
Define a hyperlinkUpdate() method as required when adding this listener.
I agree. Here's the link:
subject: JEditorPane HTML Anchor Links
It's not a secret anymore!