|
@ -0,0 +1,36 @@ |
|
|
|
|
|
package Minesweeper; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JButton; |
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
|
|
|
|
public class MinesweeperGame extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
public MinesweeperGame(int _playfieldSize) { |
|
|
|
|
|
this.setSize(600, 600); |
|
|
|
|
|
setLayout(null); |
|
|
|
|
|
initPlayfield(_playfieldSize); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initPlayfield(int _playfieldSize) { |
|
|
|
|
|
for (int i = 0; i < _playfieldSize; i++) { |
|
|
|
|
|
for (int j = 0; j < _playfieldSize; j++) { |
|
|
|
|
|
JButton b = new JButton(); |
|
|
|
|
|
b.setBounds(j * 40, i * 40, 40, 40); |
|
|
|
|
|
add(b); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
JFrame f = new JFrame(); |
|
|
|
|
|
MinesweeperGame ttt = new MinesweeperGame(8); |
|
|
|
|
|
|
|
|
|
|
|
f.add(ttt); |
|
|
|
|
|
f.setSize(600, 600); |
|
|
|
|
|
f.setLayout(null); |
|
|
|
|
|
f.setVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |