java application which will respond to clicks on the image

i want to create a java application which will respond to clicks on the image.i want to know any tutorial or help i can get to get started with it.
zolfAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Put the image in a JLabel and add a MouseListener to the label
CEHJCommented:
label = new JLabel(new ImageIcon("x.jpg"));
label.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
            // Respond
      }
});
Mick BarryJava DeveloperCommented:
yuou could use a JButton with an ActionListener.
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

zolfAuthor Commented:

      thanks for your replies.let me explain in more details.for example i get
      an image of a stero system and if i clcik on the play button it should play
      ,if i click on the stop button it should stop playing....so on.
CEHJCommented:
You need to add buttons maybe over the image? If so, implement your own JPanel and override the paintComponent method to display the image
CEHJCommented:
If you mean respond to events on the image of buttons, you need to calculate the coordinates and respond if the mouse iw within them
amol_chaudhariCommented:
hi zolf,
        there are two cases
1. if u have seperate images of play and stop buttons then u can display that images on the seperate panel or label or button and add actionListener to them.....
using mouse adapter u can catch the click event and then for each seperate compenent u can write seperate code.....

2. if all the buttons are on single image then u must keep track of XY boundaries of that buttons.. display image on panel or label add actionLIstener then using mouse adapter u can catch the mouse click event, in that routine get the xy cordinate of the mouse on image as
 event.getX();
 event.getY();

compare it with the boundaries of the button and take action accordingly....

for more help on mouse handling see.....
http://java.sun.com/docs/books/tutorial/uiswing/events/mousemotionlistener.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zolfAuthor Commented:


shivspk those sites do not open which you mentioned.do they open for you???
CEHJCommented:
:-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.