当我单击其中一个 buffereImage 时,我想发出声音。但它向我显示了这个错误: BufferedImage 类型的方法 addMouseListener(new MouseAdapter(){}) 未定义
这是代码:
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();
}
}
}