This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JEditorPane - following links within locally created HTML  RSS feed

 
David Weiler-Thiessen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating an HTML report within my application, and displaying the contents with the JEditorPane. I have put links within the HTML page to navigate to different parts of the same page; think summary at the top, and then detail sections lower down the same page. The links are meant to take you from areas on the summary to the specific detail sections. I have other links that are mean to return you to the top of the page.

I am finding that in my HyperlinkEventListener, the event.getURL() returns null, and event.getDescription() does return the href value of the link in the page. What I am having problems with is getting a valid URL that I can pass back to the JEditorPane to cause it to scroll down to detail section that matches the id within the Page that is currently being displayed.

It almost seems as if the JEditorPane doesn't know about a base directory for the page, as it is generated internally, and passed in as text to the JEditorPane.

Does anyone know how to get a valid URL for the situation I am working with?

Thanks.
 
David Weiler-Thiessen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out.

Key is calling the JEditorPane.scrollToReference method. By calling the HyperlineEvent.getDescription method I get the name of the anchor I want to jump to. Then in the HTML, I need to put <a> tags that have names that match the name I want to jump to, i.e. <a >
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!