File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 10170
    
    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!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
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