From 88de22364d8695e95d25d628e30184fd3c4a3dac Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 16:49:01 +0100 Subject: [PATCH] Add class MinesweeperGame with basic playfield gen. --- .gitignore | 21 +++++++++++ .../java/Minesweeper/MinesweeperGame.java | 36 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/test/java/Minesweeper/MinesweeperGame.java diff --git a/.gitignore b/.gitignore index 84adb3f..cfcc9bc 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,24 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven \ No newline at end of file diff --git a/src/test/java/Minesweeper/MinesweeperGame.java b/src/test/java/Minesweeper/MinesweeperGame.java new file mode 100644 index 0000000..8285a98 --- /dev/null +++ b/src/test/java/Minesweeper/MinesweeperGame.java @@ -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); + + } + +}