java - Error while adding mouseListener to BufferedImage -


i want produced sound when clicked on 1 of buffereimage. display me error: method addmouselistener(new mouseadapter(){}) undefined type bufferedimage

here code:

public class testpane extends jpanel {      public testpane() {         setlayout(new propertionallayoutmanager(400, 400));         add(new symbol(), new propertionalconstraint(0f, 0));         add(new symbol(), new propertionalconstraint(0.67f, 0));         //add(new symbol(), new propertionalconstraint(0f, 0.4675f));         //add(new symbol(), new propertionalconstraint(0.67f, 0.4675f));         add(new drum(), new propertionalconstraint(0.205f, 0.1f));         add(new drum(), new propertionalconstraint(0.5f, 0.1f));         add(new drum(), new propertionalconstraint(0f, 0.33f));         add(new drum(), new propertionalconstraint(0.705f, 0.33f));        drum.addmouselistener(new mouseadapter()      {           public void mouseclicked(mouseevent me)            {             sound1.sound5.play();           }         });        }static {      try {         symbol = imageio.read(new file("hicrash.png"));     } catch (ioexception ex) {         ex.printstacktrace();     }     try {         drum = imageio.read(new file("hitom.png"));     } catch (ioexception ex) {         ex.printstacktrace();     }  } } 

mouselistener can added component can made visible on screen. default bufferedimage can not displayed on screen, without first being wrapped component (like jlabel or painted onto surface of jpanel, example).

actually, can't add mouse listener doesn't provide support it...

instead, add mouselistener drum or symbol class

you might want take read through how write mouse listener


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -