packagegame消消乐;importjava.awt.BorderLayout;importjava.awt.FlowLayout;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjava.util.Random;import javax.swing.*;public class Myjframe extendsJFrame {private JPanel panel1 = newJPanel();private JButton buttona = new JButton("开始");private JLabel label1 = new JLabel("分数");private JTextField textarea1 = new JTextField(10);private JLabel buttonc = new JLabel("时间");private JProgressBar jindu = newJProgressBar();private Timer timer; //定时器
private JButton buttonb = new JButton("退出");private JPanel panel2 = newJPanel();private JButton button[][] = new JButton[8][8];private int animal[][] = new int[8][8];private ImageIcon Iocn[] = new ImageIcon[7];//标记是否有三个以上的连接
private final int EMPTY = 0;//无为0,有为1//随机数
private Random rand = new Random();//new 一个监听器//标记是否有三个以上的连接
private booleanisThreeLinked;//标记单击次数
private booleanisDoubleClicked;private int x1;//记录第一次被点击按钮的X坐标
private int y1;//记录第一次被点击按钮的Y坐标
private int grade = 0; //得分
Myjframe() {//加载图片
Iocn[0] = new ImageIcon("image//cat.png");
Iocn[1] = new ImageIcon("image//cattle.png");
Iocn[2] = new ImageIcon("image//chicken.png");
Iocn[3] = new ImageIcon("image//fox.png");
Iocn[4] = new ImageIcon("image//monkey.png");
Iocn[5] = new ImageIcon("image//panda.png");
Iocn[6] = new ImageIcon("image//frog.png");
panel1.setLayout(newFlowLayout());
panel1.add(buttona);
panel1.add(label1);
panel1.add(textarea1);
textarea1.setEditable(false);
textarea1.setText(Integer.toString(grade));//panel1.add(buttonc);
jindu.setMaximum(100);
panel1.add(jindu);
panel1.add(buttonb);this.setLayout(newBorderLayout());this.add(panel1, BorderLayout.NORTH);
panel2.setLayout(new GridLayout(8, 8, 1, 1));
MyListener mylisten= newMyListener();intm