diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index df527ea..33b144a 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/Current_Window.png b/Current_Window.png
new file mode 100644
index 0000000..3dfbef1
Binary files /dev/null and b/Current_Window.png differ
diff --git a/README.md b/README.md
index 3f3ac79..955c6a6 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,16 @@
# jchess
-Java chess game
\ No newline at end of file
+A chess Board writen in Java
+
+The goal of this project is to get used to javaFX. This might awefull code, don't loook to deeply!
+
+## Build & Run
+
+```shell
+$ ./gradlew build
+$ ./gradlew run
+```
+
+## Appearance
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 1225d80..7d28df9 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,6 +9,7 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
+ id 'org.openjfx.javafxplugin' version '0.0.13'
}
repositories {
@@ -29,6 +30,11 @@ application {
mainClass = 'jchess.App'
}
+javafx {
+ version = "20"
+ modules = [ 'javafx.controls']
+}
+
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
diff --git a/app/src/main/java/jchess/App.java b/app/src/main/java/jchess/App.java
index 72ab782..8423267 100644
--- a/app/src/main/java/jchess/App.java
+++ b/app/src/main/java/jchess/App.java
@@ -1,14 +1,44 @@
-/*
- * This Java source file was generated by the Gradle 'init' task.
- */
package jchess;
-public class App {
- public String getGreeting() {
- return "Hello World!";
+
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.GridPane;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Rectangle;
+import javafx.stage.Stage;
+
+public class App extends Application {
+
+ public final static int WIDTH = 500, HEIGHT = 500;
+ public final static String PROGRAM_NAME = "JChess";
+ public static void main(String[] args) {
+ launch();
}
- public static void main(String[] args) {
- System.out.println(new App().getGreeting());
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ BorderPane root = new BorderPane();
+
+ GridPane board = new GridPane();
+
+ Rectangle[][] cases = new Rectangle[8][8];
+ for (int i = 0; i < 8; i++) {
+ for (int j = 0; j < 8; j++) {
+ cases[i][j] = new Rectangle(WIDTH/8, HEIGHT/8);
+ cases[i][j].setFill((i + j) % 2 == 0 ? Color.WHITE : Color.LIGHTGRAY);
+ board.add(cases[i][j], i, j);
+ }
+ }
+
+
+ root.setCenter(board);
+ Scene scene = new Scene(root, WIDTH, HEIGHT);
+ scene.addEventHandler(KeyEvent.KEY_PRESSED, new KeyboardEvent());
+ primaryStage.setScene(scene);
+ primaryStage.setTitle(PROGRAM_NAME);
+ primaryStage.show();
}
}
diff --git a/app/src/main/java/jchess/KeyboardEvent.java b/app/src/main/java/jchess/KeyboardEvent.java
new file mode 100644
index 0000000..2008c4c
--- /dev/null
+++ b/app/src/main/java/jchess/KeyboardEvent.java
@@ -0,0 +1,16 @@
+package jchess;
+
+import javafx.application.Platform;
+import javafx.event.EventHandler;
+import javafx.scene.input.KeyCode;
+import javafx.scene.input.KeyEvent;
+
+public class KeyboardEvent implements EventHandler {
+ @Override
+ public void handle(KeyEvent event) {
+ System.out.println(event.getCharacter());
+ if(event.getCode() == KeyCode.Q){
+ Platform.exit();
+ }
+ }
+}