• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add a tooltip in an applet

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maneesh Godbole:


PS. I am using jdk1.6



Easier to attach the source code by sun.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic