Nur die besten Spiele ;3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
933 B

  1. package Minesweeper;
  2. import javax.swing.JButton;
  3. import javax.swing.JFrame;
  4. import javax.swing.JPanel;
  5. public class MinesweeperGame extends JPanel {
  6. private static final long serialVersionUID = 1L;
  7. private static final int WIDTH = 600, HEIGTH = 600;
  8. private static final int CELLSIZE = 40;
  9. private int playfieldSize;
  10. public MinesweeperGame(int _playfieldSize) {
  11. this.setSize(WIDTH, HEIGTH);
  12. playfieldSize = _playfieldSize;
  13. setLayout(null);
  14. initPlayfield();
  15. }
  16. private void initPlayfield() {
  17. for (int i = 0; i < playfieldSize; i++) {
  18. for (int j = 0; j < playfieldSize; j++) {
  19. JButton b = new JButton();
  20. b.setBounds(j * CELLSIZE, i * CELLSIZE, CELLSIZE, CELLSIZE);
  21. add(b);
  22. }
  23. }
  24. }
  25. public static void main(String[] args) {
  26. JFrame f = new JFrame();
  27. MinesweeperGame ttt = new MinesweeperGame(8);
  28. f.add(ttt);
  29. f.setSize(WIDTH, HEIGTH);
  30. f.setLayout(null);
  31. f.setVisible(true);
  32. }
  33. }