我正在尝试在单击cake节点时收到弹出消息。它打印到控制台,但“JOptionPane.showMessageDialog(null,”Test“);”当我点击蛋糕时没撞错程序(没有错误)。有什么想法吗?
class Cake extends Item {
double dx=3,dy=1.6;
Cake(String imageFile, double x, double y) {
super(imageFile, x, y);
}
@Override
public void move() {
this.setX(this.getX()+dx);
if(this.getX()>749 || this.getX()<-20) {
dx=-dx;
}
this.setY(this.getY()+dy);
if(this.getY()>530 || this.getY()<0) {
dy=-dy;
}
}
@Override
public void collision() {
//System.out.println("Cake");
JOptionPane.showMessageDialog(null,"Test");
}
}