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?
 
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
0
 
CEHJCommented:
Put the image in a JLabel and add a MouseListener to the label
0
 
CEHJCommented:
label = new JLabel(new ImageIcon("x.jpg"));
label.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
            // Respond
      }
});
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
objectsCommented:
yuou could use a JButton with an ActionListener.
0
 
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.
0
 
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
0
 
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
0
 
zolfAuthor Commented:


shivspk those sites do not open which you mentioned.do they open for you???
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.