Tag: minesweeper

扫雷艇stackoverflower

我正在为扫雷编写一种方法,如果那里没有我的话,就会打开一个小区。 如果地雷旁边没有相邻的单元格,它会打开周围没有地雷的单元格。 我经常有这个错误: 线程“AWT-EventQueue-0”中的exceptionjava.lang.StackOverflowError这是我的源代码: public void open(int row, int col) { // row = vertical index of the matrix // col = horizontal index of matrix unclicked–; butt[row][col].setEnabled(false); // disable the called button if (aray[row][col] !=0) // checks if there are no adjacent cells with an adjacent mine count >0 butt[row][col].setText(Integer.toString(aray[row][col])); else{ if(row < size-1){ […]

GUI中的递归错误

我正在为Minesweeper创建一个简单的9×9网格。 这个游戏的主要function之一是,当点击的图块没有围绕它的炸弹时,有一个递归来检查所有边。 在下面的代码中,我已经能够创建一个检查tile的上侧和左侧的函数。 如果我添加更多方向,例如下方和右方,程序将崩溃并且无法正确显示切片。 (检查//MY MAIN PROBLEM行下的方法countBorders ) //显示主GUI包Minesweeper4; public class mainFrame { public static void main(String[] args) { new Grid().setVisible(true); } } //主要代码 package Minesweeper4; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Random; import javax.swing.*; public class Grid extends JFrame implements ActionListener { private JPanel mainGrid; private JButton button1, button2; private JButton[][] […]