JEditorPane - following links within locally created HTML
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?
Re: JEditorPane - following links within locally created HTML
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 name='someName'>