This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set tool tip on the certain text in jtextpane

 
Sarah Qazi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic