The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
May 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Image Map

Posted by Matt Gerrans on December 14, 2001 at 10:24 PM


> I am doing a project on java and i have to draw a map. What i would like to know is how do i create a button so the if the button is pressed a certain action is taken for example if i had a bus stop i would have a button so that when the user presses that button information comes up about were that bus goes

I'm not entirely sure what you mean by having a button -- you don't want to stick a button on top of a your map, do you?

It would probably be more attractive and flexible to add a mouse listener to your JPanel (I assume that's where you're drawing the image) with addMouseListener(). Then you can check any click event against your array of objects which reside on the map. Each object can check whether the click was on itself and take whatever action is needed.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us