This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes How  to add a tooltip in an applet 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 add a tooltip in an applet" Watch "How  to add a tooltip in an applet" New topic
Author

How to add a tooltip in an applet

Rashmi Pant
Greenhorn

Joined: Dec 19, 2007
Posts: 25
Hi All,
I want to make an applet which consists of a map (say an applet consisting of India map).
Now what i want is to add a tooltip to this map.
I mean i want that this applet should show the desired small message(like if i am moving my cursor in Delhi it must show Delhi,again if i am moving my cursor anywhere else in this map then according to the area it will show a tool tip or message.)
I think you all get what i want to say so please tell me how i can do this.
If you did not got my question then i am giving a link just click on it ,it will take you in a new window(it is an applet).
Now move your mouse in this window you will got what i wanted to do.
That link is http://www.smartdatavision.com/products/mapapplet/demo/
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
You can add a MouseMotionListener to the component that displays the map. Its mouseMoved method provides you with MouseEvents that position the mouse got moved to. If that position is inside of an "interesting" region (say, a city you want to display a tooltip for) you can draw the text (possible on a yellow background with a black border) at that position.

Moving to the AWT/Swing/GUI forum, as there's nothing applet-specific about the problem.


Ping & DNS - my free Android networking tools app
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

Your JDK should have a Demo directory. The SwingSet Demo has a tooltip demo.
It displays a picture of a cow. If you mouse over the tail you get "Tail" as a tooltip. If you mouse over the mouth you get "Moo"! If I understand correctly, it is exactly what you want. Just take a look at the source code.

PS. I am using jdk1.6


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

Originally posted by Maneesh Godbole:


PS. I am using jdk1.6


Easier to attach the source code by sun.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add a tooltip in an applet