Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JEditorPane - following links within locally created HTML

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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?

    Thanks.


  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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'>

Similar Threads

  1. Java: Links, images, font and divisions with HTML / CSS
    By Cyloc in forum AWT / Java Swing
    Replies: 3
    Last Post: August 2nd, 2011, 01:54 PM
  2. [SOLVED] writing html file in a jeditorpane
    By nasi in forum AWT / Java Swing
    Replies: 3
    Last Post: May 8th, 2010, 10:39 PM
  3. changing the visited links color in JEditorpane
    By nasi in forum AWT / Java Swing
    Replies: 5
    Last Post: April 18th, 2010, 09:44 AM
  4. creating a controller to allow instances to be created from keyboard
    By ss7 in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 2nd, 2009, 01:30 PM
  5. [SOLVED] Program to read from created file
    By aznprdgy in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 7th, 2009, 04:51 AM

Tags for this Thread