java

推荐列表 站点导航

当前位置:首页 > 脚本编程 > java >

java_java基于swing实现的连连看代码,本文实例讲述了java基于swing实(2)

来源:互联网  作者:网友投稿  发布时间:2021-01-06 03:21
public void linePassOne() { if (y0 j) { // 第一按钮同行空按钮在左边 for (i = y0 - 1; i = j; i--) { // 判断第一按钮同左侧空按钮之间有没按钮 if (grid[x0][i] != 0) { k = 0;...
public void linePassOne() { if (y0 j) { // 第一按钮同行空按钮在左边 for (i = y0 - 1; i = j; i--) { // 判断第一按钮同左侧空按钮之间有没按钮 if (grid[x0][i] != 0) { k = 0; break; } else { k = 2; } // K=2说明通过了第二次验证 } } if (y0 j) { // 第一按钮同行空按钮在与第二按钮之间 for (i = y0 + 1; i = j; i++) { if (grid[x0][i] != 0) { k = 0; break; } else { k = 2; } } } } public void rowPassOne() { if (x0 i) { for (j = x0 - 1; j = i; j--) { if (grid[j][y0] != 0) { k = 0; break; } else { k = 2; } } } if (x0 i) { for (j = x0 + 1; j = i; j++) { if (grid[j][y0] != 0) { k = 0; break; } else { k = 2; } } } } public void remove() { &nbs , "North"); centerPanel.setLayout(new GridLayout(6, 100, fristMsg = 0, newlyButton; // 退出, resetButton, 5)); for (int cols = 0; cols 6; cols++) { for (int rows = 0; rows 5; rows++) { diamondsButton[cols][rows] = new JButton( String.valueOf(grid[cols + 1][rows + 1])); diamondsButton[cols][rows].addActionListener(this); centerPanel.add(diamondsButton[cols][rows]); } } exitButton = new JButton("退出"); exitButton.addActionListener(this); resetButton = new JButton("重列"); resetButton.addActionListener(this); newlyButton = new JButton("再来一局"); newlyButton.addActionListener(this); southPanel.add(exitButton); southPanel.add(resetButton); southPanel.add(newlyButton); fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable .getText()))); northPanel.add(fractionLable); mainFrame.setBounds(280, secondButton; // 分别记录两次被选中的按钮 int grid[][] = new int[8][7];// 储存游戏按钮位置 static boolean pressInformation = false; // 判断是否有按钮被选中 int x0 = 0, "Center"); thisContainer.add(southPanel。

重列, cols。

cols, secondMsg = 0, k。

450); mainFrame.setVisible(true); } public void randomBuild() { int randoms,仔细分析, "South"); thisContainer.add(northPanel, j, rows; int grid[][] = new int[8][7]; for (int i = 0; i = 6; i++) { for (int j = 0; j = 5; j++) { if (this.grid[i][j] != 0) { save[n] = this.grid[i][j]; n++; } } } n = n - 1; this.grid = grid; while (n = 0) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); while (grid[cols][rows] != 0) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); } this.grid[cols][rows] = save[n]; n--; } mainFrame.setVisible(false); pressInformation = false; // 这里一定要将按钮点击信息归为初始 init(); for (int i = 0; i 6; i++) { for (int j = 0; j 5; j++) { if (grid[i + 1][j + 1] == 0) diamondsButton[i][j].setVisible(false); } } } public void estimateEven(int placeX, rows; for (int twins = 1; twins = 15; twins++) { randoms = (int) (Math.random() * 25 + 1); for (int alike = 1; alike = 2; alike++) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); while (grid[cols][rows] != 0) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); } this.grid[cols][rows] = randoms; } } } public void fraction() { fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable .getText()) + 100)); } public void reload() { int save[] = new int[30]; int n = 0, northPanel; // 子面板 JButton diamondsButton[][] = new JButton[6][5];// 游戏按钮数组 JButton exitButton, y = 0,。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/java/11330.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

java_java基于swing实现的连连看代码,本文实例讲述了java基于swing实(2)

2021-01-06 编辑:网友投稿

public void linePassOne() { if (y0 j) { // 第一按钮同行空按钮在左边 for (i = y0 - 1; i = j; i--) { // 判断第一按钮同左侧空按钮之间有没按钮 if (grid[x0][i] != 0) { k = 0; break; } else { k = 2; } // K=2说明通过了第二次验证 } } if (y0 j) { // 第一按钮同行空按钮在与第二按钮之间 for (i = y0 + 1; i = j; i++) { if (grid[x0][i] != 0) { k = 0; break; } else { k = 2; } } } } public void rowPassOne() { if (x0 i) { for (j = x0 - 1; j = i; j--) { if (grid[j][y0] != 0) { k = 0; break; } else { k = 2; } } } if (x0 i) { for (j = x0 + 1; j = i; j++) { if (grid[j][y0] != 0) { k = 0; break; } else { k = 2; } } } } public void remove() { &nbs , "North"); centerPanel.setLayout(new GridLayout(6, 100, fristMsg = 0, newlyButton; // 退出, resetButton, 5)); for (int cols = 0; cols 6; cols++) { for (int rows = 0; rows 5; rows++) { diamondsButton[cols][rows] = new JButton( String.valueOf(grid[cols + 1][rows + 1])); diamondsButton[cols][rows].addActionListener(this); centerPanel.add(diamondsButton[cols][rows]); } } exitButton = new JButton("退出"); exitButton.addActionListener(this); resetButton = new JButton("重列"); resetButton.addActionListener(this); newlyButton = new JButton("再来一局"); newlyButton.addActionListener(this); southPanel.add(exitButton); southPanel.add(resetButton); southPanel.add(newlyButton); fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable .getText()))); northPanel.add(fractionLable); mainFrame.setBounds(280, secondButton; // 分别记录两次被选中的按钮 int grid[][] = new int[8][7];// 储存游戏按钮位置 static boolean pressInformation = false; // 判断是否有按钮被选中 int x0 = 0, "Center"); thisContainer.add(southPanel。

重列, cols。

cols, secondMsg = 0, k。

450); mainFrame.setVisible(true); } public void randomBuild() { int randoms,仔细分析, "South"); thisContainer.add(northPanel, j, rows; int grid[][] = new int[8][7]; for (int i = 0; i = 6; i++) { for (int j = 0; j = 5; j++) { if (this.grid[i][j] != 0) { save[n] = this.grid[i][j]; n++; } } } n = n - 1; this.grid = grid; while (n = 0) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); while (grid[cols][rows] != 0) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); } this.grid[cols][rows] = save[n]; n--; } mainFrame.setVisible(false); pressInformation = false; // 这里一定要将按钮点击信息归为初始 init(); for (int i = 0; i 6; i++) { for (int j = 0; j 5; j++) { if (grid[i + 1][j + 1] == 0) diamondsButton[i][j].setVisible(false); } } } public void estimateEven(int placeX, rows; for (int twins = 1; twins = 15; twins++) { randoms = (int) (Math.random() * 25 + 1); for (int alike = 1; alike = 2; alike++) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); while (grid[cols][rows] != 0) { cols = (int) (Math.random() * 6 + 1); rows = (int) (Math.random() * 5 + 1); } this.grid[cols][rows] = randoms; } } } public void fraction() { fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable .getText()) + 100)); } public void reload() { int save[] = new int[30]; int n = 0, northPanel; // 子面板 JButton diamondsButton[][] = new JButton[6][5];// 游戏按钮数组 JButton exitButton, y = 0,。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/java/11330.shtml

相关文章

风云图片

推荐阅读

返回java频道首页