• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to select hyperlinks in html in JEditorPane?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I don't know whether anyone can help me with this but I have a simple help facility in my application that reads an html file into a JEditorPane which is added to a JScrollPane and then the scroll pane is displyed on the screen in a JFrame.
So far so good - the html file is read in and all appears on the screen excatly as I want it to be. The problem is that the file contains several hyperlinks that should allow the user to jump around in the file without having to scroll up and down but I can't work out how to select the hyperlinks in the first place.
The api documents the key presses to use but I think I am right in thinking that the JEditorPane needs to have focus for these to work. I added a DefaultFocusTraversalPolicy to the editor pane but this had no effect, the screen is still unresponsive.

If anyone has any ideas on this I'd be very grateful.
Thanks
Sam
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may not be answering the question that you are actually asking, but here goes:
Are you implementing the hyperLinkUpdate method? If not, let your JFrame implement HyperLinkListener and then supply the implementation of hyperLinkUpdate. (Or something like that). It will respond to hyperlink events, and you specify what page to display in the method.

-BJ
[ March 14, 2003: Message edited by: BJ Grau ]
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can define links in your html pages and then you can jump to these links. In HTML you can use NAME tag to create the link and then set HREF to the link.
 
Sam O'Neill
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks BJ and Samual, it was the indeed that hyperlinkUpdate() needed to be implemented. The official API is not very clear on this so if anyone else is a bit unseure how to get it working there is a good exmaple in the book 'Professional Java Programming! by Wrox on 170.
Thanks again Sam
 
Your mother is a hamster and your father smells of tiny ads!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic