This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 10167
    
    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!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to set tool tip on the certain text in jtextpane
 
Similar Threads
Displaying all of the text in a JTextPane How???
JTextPane problem
Ajax and tooltip
How to calculate size of JLabel and resize it depending on its text?
How to change cursor height based on Font size