public class Shrewmouse extends JFrame implements Runnable
{
private static final long serialVersionUID = 8752899717443325480L;
private JLabel[] mouses;
private ImageIcon imgMouse;
public static void main(String args[])
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
Shrewmouse frame = new Shrewmouse();
frame.setVisible(true);
new Thread(frame).start();
} catch (Exception e)
{
e.printStackTrace();
}
}
});
}
public Shrewmouse()
{
super();
setResizable(false);
getContentPane().setLayout(null);
setTitle("打地鼠游戏");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon img = new ImageIcon(getClass().getResource("C:/background.jpg"));
imgMouse = new ImageIcon(getClass().getResource("C:/mouse.png"));
mouses = new JLabel[6];
for (int i = 0; i < 6; i++)
{
mouses[i] = new JLabel();
mouses[i].setSize(imgMouse.getIconWidth(), imgMouse.getIconHeight());
mouses[i].addMouseListener(new MouseAdapter()
{