From 82bc4b10fd689bf809488f536699bdd9e4dc24af Mon Sep 17 00:00:00 2001 From: fdai6499 Date: Wed, 4 Jan 2023 18:56:16 +0100 Subject: [PATCH] removed Main2 and started the initial commit as master --- sudokuExample/src/Main.java | 98 +++++++++++++++++------------------- sudokuExample/src/Main2.java | 55 -------------------- 2 files changed, 47 insertions(+), 106 deletions(-) delete mode 100644 sudokuExample/src/Main2.java diff --git a/sudokuExample/src/Main.java b/sudokuExample/src/Main.java index 095cb2d..53ed910 100644 --- a/sudokuExample/src/Main.java +++ b/sudokuExample/src/Main.java @@ -1,59 +1,55 @@ -import java.util.Scanner; +import javax.swing.*; +import javax.swing.border.EmptyBorder; -class Main { - - //sudoku counts from 1 to 9 - sCount - static final int SCOUNT = 9; - - static int field[][] = new int[SCOUNT][SCOUNT]; - int ar[] = new int[2]; +public class Main { public static void main(String[] args) { - while (true) { //das program läuft unendlich - - int[] transaction = readInput(); //starte die methode readinput und die soll werte zurückgeben - - //der erste wert von dem array transaction steht für die spalte und der zweite für die reihe und der dritte für den wert den man schreiben will - field[transaction[0]][transaction[1]] = transaction[2]; - - //gebe das gespeicherte feld auf der console aus - output(field); - - - } - } - - private static void output(int[][] field) { - - for (int i = 0; i < SCOUNT; i++) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { - for (int j = 0; j < SCOUNT; j++) { - - System.out.print(field[i][j] + " "); } - - System.out.println(); - } - - } - - static int[] readInput() { - - Scanner scanner = new Scanner(System.in); - String line = scanner.nextLine(); - System.out.println(line); - - String substring = line.substring(line.indexOf('(')+1, line.indexOf(')')); - - String[] split = substring.split(","); - - int[] transaction = new int[split.length]; - for (int i = 0; i < split.length; i++) { - transaction[i] = Integer.valueOf(split[i]); - } - - return transaction; + }); } -} \ No newline at end of file +} + + +// JFrame jFrame = new JFrame(); +// jFrame.setVisible(true); +// jFrame.setBounds(300, 300, 500, 500); +// +// JPanel yPanel = new JPanel(); +// yPanel.setLayout(new BoxLayout(yPanel, BoxLayout.Y_AXIS)); +// yPanel.setBorder(new EmptyBorder(1, 0, 1,0)); +// +// JButton jButton1 = new JButton(); +// jButton1.setText("Test Button 1"); +// +// yPanel.add(jButton1); +// +// JButton jButton2 = new JButton(); +// jButton2.setText("Test Button 2"); +// yPanel.add(jButton2); +// +// for (int i = 0; i < 9; i++) { +// +// JPanel xPanel = new JPanel(); +// xPanel.setLayout(new BoxLayout(xPanel, BoxLayout.X_AXIS)); +// xPanel.setBorder(new EmptyBorder(0, 1, 0,1)); +// +// for (int j = 0; j < 9; j++) { +// +// JTextField jTextField = new JTextField(); +// jTextField.setColumns(1); +// jTextField.setBounds(0, 0, 10, 10); +// +// xPanel.add(jTextField); +// +// } +// +// yPanel.add(xPanel); +// } +// +// jFrame.setContentPane(yPanel); diff --git a/sudokuExample/src/Main2.java b/sudokuExample/src/Main2.java deleted file mode 100644 index 346d247..0000000 --- a/sudokuExample/src/Main2.java +++ /dev/null @@ -1,55 +0,0 @@ -import javax.swing.*; -import javax.swing.border.EmptyBorder; -import java.awt.*; - -public class Main2 { - - public static void main(String[] args) { - - java.awt.EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - - JFrame jFrame = new JFrame(); - jFrame.setVisible(true); - jFrame.setBounds(300, 300, 500, 500); - - JPanel yPanel = new JPanel(); - yPanel.setLayout(new BoxLayout(yPanel, BoxLayout.Y_AXIS)); - yPanel.setBorder(new EmptyBorder(1, 0, 1,0)); - - JButton jButton1 = new JButton(); - jButton1.setText("Test Button 1"); - - yPanel.add(jButton1); - - JButton jButton2 = new JButton(); - jButton2.setText("Test Button 2"); - yPanel.add(jButton2); - - for (int i = 0; i < 9; i++) { - - JPanel xPanel = new JPanel(); - xPanel.setLayout(new BoxLayout(xPanel, BoxLayout.X_AXIS)); - xPanel.setBorder(new EmptyBorder(0, 1, 0,1)); - - for (int j = 0; j < 9; j++) { - - JTextField jTextField = new JTextField(); - jTextField.setColumns(1); - jTextField.setBounds(0, 0, 10, 10); - - xPanel.add(jTextField); - - } - - yPanel.add(xPanel); - } - - jFrame.setContentPane(yPanel); - - } - }); - } -}