It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes url tooltip in JEditorPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "url tooltip in JEditorPane" Watch "url tooltip in JEditorPane" New topic

url tooltip in JEditorPane

Ranch Hand

Joined: Nov 21, 2000
Posts: 71
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
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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...


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: url tooltip in JEditorPane
It's not a secret anymore!