This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add a tooltip in an applet

 
Rashmi Pant
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maneesh Godbole:


PS. I am using jdk1.6


Easier to attach the source code by sun.

 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic