class LianLianKanJPanel extends JPanel implements ActionListener,ItemListener {
private static final long serialVersionUID = 1L;//序列化时为了保持版本的兼容性,即在版本升级时反序列化仍保持对象的唯一性。
private int[][] map = new int[8][8];//8*8的正方形
private int kind, randomx, randomy, randomx1, randomy1; // 种类,随机x
private int coordinatex, coordinatey, coordinatex1, coordinatey1; // 坐标X
private Point lineStart = new Point(0, 0);
private int clicktimes;
private int jishushengyu;//计数剩余
private int Kinds = 4;
private int score;
private int guanshu;//关数
loudou ld = new loudou();// 漏斗
JButton BlockButton[][] = new JButton[8][8];//
Choice difficultChoice = new Choice();
JButton newgameButton = new JButton("重新开始");
JButton reLoad = new JButton("刷新");
ImageIcon ii = new ImageIcon("src/im/bk.jpg");
ImageIcon aIcon = new ImageIcon("src/im/1.gif");
ImageIcon bIcon = new ImageIcon("src/im/2.gif");
ImageIcon cIcon = new ImageIcon("src/im/3.gif");
ImageIcon dIcon = new ImageIcon("src/im/4.gif");
ImageIcon eIcon = new ImageIcon("src/im/5.gif");
ImageIcon fIcon = new ImageIcon("src/im/6.gif");
ImageIcon gIcon = new ImageIcon("src/im/7.gif");
ImageIcon hIcon = new ImageIcon("src/im/8.gif");
ImageIcon iIcon = new ImageIcon("src/im/9.gif");
ImageIcon jIcon = new ImageIcon("src/im/10.gif");
ImageIcon kIcon = new ImageIcon("src/im/11.gif");
ImageIcon lIcon = new ImageIcon("src/im/12.gif");
ImageIcon mIcon = new ImageIcon("src/im/13.gif");
ImageIcon nIcon = new ImageIcon("src/im/14.gif");
ImageIcon oIcon = new ImageIcon("src/im/15.gif");
public LianLianKanJPanel() {
this.setLayout(null);
newMap();
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
BlockButton[i][j] = new JButton();
add(BlockButton[i][j]);
BlockButton[i][j].addActionListener(this);//监听器
BlockButton[i][j].setBounds(30 + j * 40, 30 + i * 40, 31,34);
// BlockButton[i][j].setBorderPainted(false);
// BlockButton[i][j].setVisible(true);
}
}
difficultChoice.add("简单");
difficultChoice.add("中等");
difficultChoice.add("困难");
difficultChoice.add("变态");
newgameButton.setBounds(map[0].length * 40 + 80, 40, 100, 20);
newgameButton.setBackground(Color.white);
newgameButton.setBorderPainted(false); //去边框
reLoad.setBounds(map[0].length * 40 + 100, 80, 60, 20);
reLoad.setBackground(Color.white);
reLoad.setBorderPainted(false);
difficultChoice.setBounds(map[0].length * 40 + 100, 120, 60, 20);
difficultChoice.addItemListener(this);
newgameButton.addActionListener(this);
reLoad.addActionListener(this);
this.add(newgameButton);
this.add(reLoad);
this.add(difficultChoice);
// /-------------------------漏斗
ld.setBounds(map[0].length * 40 + 100, 200, 70, 150);// 漏斗
ld.setBackground(Color.black);
this.add(ld);
}
基于Swing的连连看小游戏
猜你喜欢
转载自blog.csdn.net/qq_41383905/article/details/105196811
今日推荐
周排行