setMessage();//设置一些提示信息
//在背景图片的基础上设置地鼠图片
ImageIcon imageMouse = new ImageIcon(dir+"dishu.png");
jlbMouse = new JLabel(imageMouse);
jlbMouse.setSize(80,80);
this.getContentPane().add(jlbMouse);
jlbMouse.setVisible(false);
jlbMouse.addMouseListener(this);//添加鼠标监听
//定时器
timer = new Timer(delay,this);
random = new Random();
timer.start();
int ran=random.nextInt(9);//随机生成一个0~9(不包括9)的随机数
ImageIcon imageMouse = new ImageIcon(dir+"dishu.png");//保证每次随机生成的地鼠图片都是为没被打时的图片
jlbMouse.setIcon(imageMouse);
switch(ran){
case 0:jlbMouse.setLocation(55, 63);break;
case 1:jlbMouse.setLocation(321, 204);break;
case 2:jlbMouse.setLocation(184, 204);break;
case 3:jlbMouse.setLocation(47, 203);break;
case 4:jlbMouse.setLocation(297, 133);break;
case 5:jlbMouse.setLocation(161, 133);break;
case 6:jlbMouse.setLocation(21, 133);break;
case 7:jlbMouse.setLocation(310, 63);break;
case 8:jlbMouse.setLocation(185, 63);break;
}