扫雷源码 + 素材 for (int x = 0; x < widthx; x++) { for (int y = 0; y < highty; y++) { gridBlank[x][y] = new Blank(); // grid[x][y].addMouseListener(); } } // 开始布雷 count = 40; do { for (int x = 0; x < widthx; x++) { for (int y = 0; y < highty; y++) { if (count > 0) { if (!(gridBlank[x][y] instanceof Bomb)) { rdm = new Random().nextInt(widthx * highty / 40); if (rdm == 1) { gridBlank[x][y] = new Bomb(); count--; } } else { contin ue; } } else { break; } } } } while (count > 0);