It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes How to set tool tip on the certain text in jtextpane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set tool tip on the certain text in jtextpane" Watch "How to set tool tip on the certain text in jtextpane" New topic
Author

How to set tool tip on the certain text in jtextpane

Sarah Qazi
Greenhorn

Joined: Oct 18, 2013
Posts: 6
Hi,

I want to add tooltip on the certain text in jtextpane. Can anyone show me how to do this. For example I want to add the location of text on which it is present in string in tooltip. When the user hover the mouse on that area it will show the location of text. I had search the problem but I have found that I had to override gettooltip method. I do not how to do this.

Please tell me how should I solve my problem?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

In pseudo code
1) getToolTipText(MouseEvent event)
2) Using the event object, figure out the x,y coordinates
3) Using the co-ordinates figure out which part of the text the mouse is hovering over
4) Provide relevant text based on the text


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
Don't get me started about those stupid light bulbs.
 
subject: How to set tool tip on the certain text in jtextpane