Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

url tooltip in JEditorPane

 
NILESH PATEL
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I have created a JEditorPane, which takes html page as part of setpage method. The problem is, when html page has a tag like this:
<a href="#chapter4" title="Got to chapter 4">chapter 4</a>
In IE title is displayed as a tooltip, but in JEditorPane, loading same html page, tooltip is not displayed. Does someone know whether I need to use any method from java to turn this feature ON or something similar.
Thanks in advance
Nilesh
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you would have to implement that yourself... Though I think it would be pretty easy to do. I think that you would extend your JEditorPane's getToolTipText( MouseEvent ) and getToolTipLocation( MouseEvent ) methods. In these methods, find out where the mouse event is and see if there is a link on the JEditorPane at that point. If there is then display a tooltip based on some property of that link. Title is kind of a pain because you'll have to load the html of that page in a buffer and get the title from it. Seems a little bit inefficient...

-Nate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic