This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JEditorPane HTML Anchor Links" Watch "JEditorPane HTML Anchor Links" New topic
Author

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.
David
Javaoops
Ranch Hand

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

Javaoops
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: http://aspose.com/file-tools
 
subject: JEditorPane HTML Anchor Links
 
Similar Threads
Help Info.
Hyperlinks in JEditorPane
Question about hyperlink...
anchor tags within the jeditorpane
how to activate html-links in a JEditor pane