Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Event listener of image (http://www.go4expert.com/forums/event-listener-image-t25214/)

shane5317 10Mar2011 18:51

Event listener of image
Hi all,
I am Beginner of Java.I having problems with the event listener. I have created image and successfully display on the screen. My problem is i don't have any ideas how to add the event listener onto image. Any tutorials?
For example,

JButton button = new JButton("click me");
button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e)
//Execute when button is pressed
JOptionPane.showMessageDialog(null,"You clicked the button");

How about image??I have image like this
Image img;
MediaTracker mt = new MediaTracker(this);
img = Toolkit.getDefaultToolkit().getImage("image1/Sleet.png");
//what should i do next

i want to perform just like button??can i do that?Anyone please help me!!:embarasse

virxen 12Mar2011 05:56

Re: Event listener of image
use a jlabel instead


shane5317 13Mar2011 17:16

Re: Event listener of image
thanks so much. =D

All times are GMT +5.5. The time now is 11:12.