From 093c9bf60191332bfba4e36037f1fd3a51faf58d Mon Sep 17 00:00:00 2001 From: beratkocak Date: Fri, 20 Dec 2024 13:45:39 +0100 Subject: [PATCH 1/7] added main menu to menugui class --- .../pr2projekt/gui/HighscoreGUI.java | 5 ++ .../informatik/pr2projekt/gui/MenuGUI.java | 64 ++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java index 8c51b8b..e79415f 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java @@ -2,4 +2,9 @@ package de.hs_mannheim.informatik.pr2projekt.gui; public class HighscoreGUI { + public static void highscoreScreen() { + // TODO Auto-generated method stub + + } + } diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java index 504729c..ea98b17 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java @@ -1,6 +1,66 @@ package de.hs_mannheim.informatik.pr2projekt.gui; -public class MenuGUI { +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.io.FileNotFoundException; +import java.util.Stack; - //ABC +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + + +public class MenuGUI { + + public static void getPath(String[] filepath){ + String[] filepath0 = new String[2]; + JFrame frame = new JFrame("Hitori"); + JPanel menuPanel = new JPanel(new BorderLayout()); + JPanel buttonPanel = new JPanel(new GridLayout(7,1,10,10)); + String[] buttons = { + "4x4 - leicht", + "5x5 - leicht", + "8x8 - leicht", + "8x8 - medium", + "10x10 - medium", + "15x15 - medium" + }; + for(int i=0;i { + int j = count[0]; + String[] paths = { + "Hitori_Spielfelder2/Hitori4x4_leicht.csv", + "Hitori_Spielfelder2/Hitori5x5leicht.csv", + "Hitori_Spielfelder2/Hitori8x8leicht.csv", + "Hitori_Spielfelder2/Hitori8x8medium.csv", + "Hitori_Spielfelder2/Hitori10x10medium.csv", + "Hitori_Spielfelder2/Hitori15x15_medium.csv" + }; + filepath0[0] = paths[j]; + filepath0[1] = row[0]; + filepath[0] = filepath0[0]; + filepath[1] = filepath0[1]; + frame.dispose(); + }); + } + JButton b = new JButton("Highscores"); + b.addActionListener(e -> { + HighscoreGUI.highscoreScreen(); + frame.dispose(); + }); + buttonPanel.add(b); + frame.setVisible(true); + frame.setSize(600,600); + menuPanel.add(buttonPanel, BorderLayout.CENTER); + JLabel text0 = new JLabel("Wählen Sie ein Level aus!"); + menuPanel.add(text0, BorderLayout.NORTH); + frame.setDefaultCloseOperation(0); + frame.add(menuPanel); + } } From 2aaac10f486793d87d6cbe97d41dca0f46a32976 Mon Sep 17 00:00:00 2001 From: beratkocak Date: Fri, 20 Dec 2024 13:48:46 +0100 Subject: [PATCH 2/7] added highscore jframe to highscore gui --- .../pr2projekt/gui/HighscoreGUI.java | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java index e79415f..104b3a6 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java @@ -1,10 +1,60 @@ package de.hs_mannheim.informatik.pr2projekt.gui; +import java.awt.BorderLayout; +import java.awt.GridLayout; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + public class HighscoreGUI { - public static void highscoreScreen() { - // TODO Auto-generated method stub - - } + public static void highscoreScreen(String[] filepath){ + JFrame frame = new JFrame("Highscores"); + JPanel highscorePanel = new JPanel(new BorderLayout()); + JPanel buttonPanel = new JPanel(new GridLayout(7,1,10,10)); + String[] buttons = { + "Highscore 4x4 - leicht", + "Highscore 5x5 - leicht", + "Highscore 8x8 - leicht", + "Highscore 8x8 - medium", + "Highscore 10x10 - medium", + "Highscore 15x15 - medium" + }; + for(int i=0;i { + int j = count[0]; + String[] paths = { + "Hitori_Highscores/Hitori4x4_leicht.txt", + "Hitori_Highscores/Hitori5x5leicht.txt", + "Hitori_Highscores/Hitori8x8leicht.txt", + "Hitori_Highscores/Hitori8x8medium.txt", + "Hitori_Highscores/Hitori10x10medium.txt", + "Hitori_Highscores/Hitori15x15_medium.txt" + }; + showHighscores(paths[j]); + frame.dispose(); + }); + } + JButton b = new JButton("Zurück"); + b.addActionListener(e -> { + frame.dispose(); + MenuGUI.getPath(filepath); + }); + buttonPanel.add(b); + frame.setVisible(true); + frame.setSize(600,600); + highscorePanel.add(buttonPanel, BorderLayout.CENTER); + JLabel text0 = new JLabel("Level für Highscore Liste auswählen!"); + highscorePanel.add(text0, BorderLayout.NORTH); + frame.setDefaultCloseOperation(0); + frame.add(highscorePanel); + } } From cf38b86df1bba8ef77ee06582a16f09c81aba3ea Mon Sep 17 00:00:00 2001 From: beratkocak Date: Fri, 20 Dec 2024 13:55:22 +0100 Subject: [PATCH 3/7] added paint game method to take input from csv reading method and make a jframe of buttons --- .../informatik/pr2projekt/gui/GameGUI.java | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java index 94d435d..bef0c28 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java @@ -1,5 +1,70 @@ package de.hs_mannheim.informatik.pr2projekt.gui; -public class GameGUI { +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import java.io.FileNotFoundException; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain; + +public class GameGUI { + private static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack madeMoves, String[][] data){ + JFrame frame = new JFrame(); + int num = buttons.length; + JPanel gameGrid = new JPanel(new GridLayout(num,num,0,0)); + for(int i=0;i {paintButton(b, pos, colors , madeMoves);}); + } + } + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(gameGrid, BorderLayout.CENTER); + JPanel buttonGrid = new JPanel(new GridLayout(1,4,10,10)); + JButton b0 = new JButton("Aufgeben"); + b0.addActionListener(e -> { + frame.dispose(); + MenuGUI.getPath(filepath); + }); + JButton b1 = new JButton("Zurück"); + b1.addActionListener(e -> {backOneStep(madeMoves, buttons, colors,gameGrid);}); + JButton b2 = new JButton("Zurücksetzen"); + b2.addActionListener(e -> {totalResetButton(buttons, colors, madeMoves, data);}); + JButton b3 = new JButton("Abgeben"); + String path = filepath[0]; + b3.addActionListener(e -> { + try{ + boolean levelFinished = HitoriMain.abgabeMöglich(path, data, colors); + if(levelFinished == true){ + HitoriMain.finish(path, data, colors); + frame.dispose(); + } else { + JLabel text1 = new JLabel("Abgabe nicht richtig!"); + mainPanel.add(text1, BorderLayout.NORTH); + mainPanel.revalidate(); + mainPanel.repaint(); + } + } catch (FileNotFoundException i) { + System.out.println("File not found: " + i.getMessage()); + } + }); + buttonGrid.add(b0);buttonGrid.add(b1);buttonGrid.add(b2);buttonGrid.add(b3); + mainPanel.add(buttonGrid, BorderLayout.SOUTH); + mainPanel.setVisible(true); + frame.add(mainPanel); + frame.setVisible(true); + frame.setSize(600,600); + } } From 1e640026f784d9fbe453ec88c7af3e8e08264381 Mon Sep 17 00:00:00 2001 From: beratkocak Date: Fri, 20 Dec 2024 13:57:57 +0100 Subject: [PATCH 4/7] added paint button to color the buttons after user press --- .../informatik/pr2projekt/gui/GameGUI.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java index bef0c28..0029561 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java @@ -4,6 +4,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import java.io.FileNotFoundException; +import java.util.Stack; import javax.swing.JButton; import javax.swing.JFrame; @@ -67,4 +68,43 @@ public class GameGUI { frame.setVisible(true); frame.setSize(600,600); } + + private static void paintButton(JButton b, String[] pos, String[][] colors, Stack madeMoves){ + int i = Integer.parseInt(pos[0]); + int j = Integer.parseInt(pos[1]); + String col = colors[Integer.parseInt(pos[0])][Integer.parseInt(pos[1])]; + if(col.endsWith("W")){ + b.setOpaque(true); + b.setForeground(Color.BLACK); + b.setContentAreaFilled(true); + b.setBorderPainted(false); + b.setFocusPainted(false); + b.setBackground(Color.lightGray); + colors[i][j] += "G"; + String logEntrance = i+"."+j+"."+"G"; + madeMoves.push(logEntrance); + } + if(col.endsWith("G")){ + b.setOpaque(true); + b.setForeground(Color.WHITE); + b.setContentAreaFilled(true); + b.setBorderPainted(false); + b.setFocusPainted(false); + b.setBackground(Color.BLACK); + colors[i][j] += "B"; + String logEntrance = i+"."+j+"."+"B"; + madeMoves.push(logEntrance); + } + if(col.endsWith("B")){ + b.setOpaque(true); + b.setForeground(Color.BLACK); + b.setContentAreaFilled(true); + b.setBorderPainted(false); + b.setFocusPainted(false); + b.setBackground(Color.WHITE); + colors[i][j] += "W"; + String logEntrance = i+"."+j+"."+"W"; + madeMoves.push(logEntrance); + } + } } From 6a505ef34d9e29217090ff56e05520ef602e3d9f Mon Sep 17 00:00:00 2001 From: beratkocak Date: Fri, 20 Dec 2024 14:00:39 +0100 Subject: [PATCH 5/7] added gridUpdate to refrech gameGrid after user press to revalidate colors of buttons --- .../informatik/pr2projekt/gui/GameGUI.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java index 0029561..59cc330 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java @@ -14,7 +14,8 @@ import javax.swing.JPanel; import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain; public class GameGUI { - private static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack madeMoves, String[][] data){ + + public static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack madeMoves, String[][] data){ JFrame frame = new JFrame(); int num = buttons.length; JPanel gameGrid = new JPanel(new GridLayout(num,num,0,0)); @@ -40,9 +41,9 @@ public class GameGUI { MenuGUI.getPath(filepath); }); JButton b1 = new JButton("Zurück"); - b1.addActionListener(e -> {backOneStep(madeMoves, buttons, colors,gameGrid);}); + b1.addActionListener(e -> {HitoriMain.backOneStep(madeMoves, buttons, colors, gameGrid);}); JButton b2 = new JButton("Zurücksetzen"); - b2.addActionListener(e -> {totalResetButton(buttons, colors, madeMoves, data);}); + b2.addActionListener(e -> {HitoriMain.totalResetButton(buttons, colors, madeMoves, data);}); JButton b3 = new JButton("Abgeben"); String path = filepath[0]; b3.addActionListener(e -> { @@ -69,7 +70,7 @@ public class GameGUI { frame.setSize(600,600); } - private static void paintButton(JButton b, String[] pos, String[][] colors, Stack madeMoves){ + public static void paintButton(JButton b, String[] pos, String[][] colors, Stack madeMoves){ int i = Integer.parseInt(pos[0]); int j = Integer.parseInt(pos[1]); String col = colors[Integer.parseInt(pos[0])][Integer.parseInt(pos[1])]; @@ -106,5 +107,18 @@ public class GameGUI { String logEntrance = i+"."+j+"."+"W"; madeMoves.push(logEntrance); } + + public static void gridUpdate(JPanel grid, JButton[][] buttons){ + grid.removeAll(); + grid.repaint(); + for(int i = 0; i Date: Fri, 20 Dec 2024 14:04:03 +0100 Subject: [PATCH 6/7] added backonestep method to retract steps from user and repaint panel --- .../informatik/pr2projekt/gui/GameGUI.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java index 59cc330..03d5170 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java @@ -108,6 +108,63 @@ public class GameGUI { madeMoves.push(logEntrance); } + public static void backOneStep(Stack movesMade, JButton[][] buttons, String[][] colors, JPanel grid){ + try { + String move = movesMade.pop(); + String[] line = move.split("\\."); + String y = line[0]; + String x = line[1]; + String color = line[2]; + if(color.equals("W")){ + int i = Integer.parseInt(y); + int j = Integer.parseInt(x); + JButton b0 = buttons[i][j]; + b0.setOpaque(true); + b0.setForeground(Color.WHITE); + b0.setContentAreaFilled(true); + b0.setBorderPainted(false); + b0.setFocusPainted(false); + b0.setBackground(Color.BLACK); + buttons[i][j] = b0; + String str = colors[i][j]; + String str0 = str.substring(0, str.length() - 1); + colors[i][j] = str0; + grid.repaint(); + gridUpdate(grid, buttons); + }else if(color.equals("G")){ + int i = Integer.parseInt(y); + int j = Integer.parseInt(x); + JButton b0 = buttons[i][j]; + b0.setOpaque(true); + b0.setForeground(Color.BLACK); + b0.setContentAreaFilled(true); + b0.setBorderPainted(false); + b0.setFocusPainted(false); + b0.setBackground(Color.WHITE); + buttons[i][j] = b0; + String str = colors[i][j]; + String str0 = str.substring(0, str.length() - 1); + colors[i][j] = str0; + gridUpdate(grid, buttons); + } else if(color.equals("B")){ + int i = Integer.parseInt(y); + int j = Integer.parseInt(x); + JButton b0 = buttons[i][j]; + b0.setOpaque(true); + b0.setForeground(Color.BLACK); + b0.setContentAreaFilled(true); + b0.setBorderPainted(false); + b0.setFocusPainted(false); + b0.setBackground(Color.lightGray); + buttons[i][j] = b0; + String str = colors[i][j]; + String str0 = str.substring(0, str.length() - 1); + colors[i][j] = str0; + gridUpdate(grid, buttons); + } + } catch(EmptyStackException e) {} + } + public static void gridUpdate(JPanel grid, JButton[][] buttons){ grid.removeAll(); grid.repaint(); From 8171a410cc080a73b565aaed9934eae3f77f946b Mon Sep 17 00:00:00 2001 From: beratkocak Date: Fri, 20 Dec 2024 14:13:45 +0100 Subject: [PATCH 7/7] added highscore maker to highscore gui --- .../informatik/pr2projekt/gui/GameGUI.java | 32 +++++++- .../pr2projekt/gui/HighscoreGUI.java | 79 ++++++++++++++++++- .../informatik/pr2projekt/gui/MenuGUI.java | 2 +- 3 files changed, 109 insertions(+), 4 deletions(-) diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java index 03d5170..b31addd 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/GameGUI.java @@ -4,12 +4,14 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import java.io.FileNotFoundException; +import java.util.EmptyStackException; import java.util.Stack; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JTextField; import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain; @@ -50,7 +52,7 @@ public class GameGUI { try{ boolean levelFinished = HitoriMain.abgabeMöglich(path, data, colors); if(levelFinished == true){ - HitoriMain.finish(path, data, colors); + GameGUI.finish(filepath, path, data, colors); frame.dispose(); } else { JLabel text1 = new JLabel("Abgabe nicht richtig!"); @@ -107,6 +109,7 @@ public class GameGUI { String logEntrance = i+"."+j+"."+"W"; madeMoves.push(logEntrance); } + } public static void backOneStep(Stack movesMade, JButton[][] buttons, String[][] colors, JPanel grid){ try { @@ -177,5 +180,30 @@ public class GameGUI { } } - } + public static void finish(String[] filepath, String path, String[][] data, String[][] colors) throws FileNotFoundException{ + JFrame frame = new JFrame("Highscore anlegen"); + JPanel mainPanel = new JPanel(new BorderLayout()); + JLabel text = new JLabel("Geben Sie unten Ihren Namen an um sich in der Highscore Liste einzutragen."); + mainPanel.add(text, BorderLayout.NORTH); + JTextField field = new JTextField(20); + mainPanel.add(field, BorderLayout.CENTER); + JButton b = new JButton("In der Highscore Liste eintragen"); + mainPanel.add(b, BorderLayout.SOUTH); + frame.setVisible(true); + frame.setSize(600,600); + frame.add(mainPanel); + b.addActionListener(e -> { + String username = field.getText(); + try { + HighscoreGUI.newRecord(path, username); + frame.dispose(); + } catch (FileNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MenuGUI.getPath(filepath); + }); + filepath[0] = ""; + filepath[1] = ""; + } } diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java index 104b3a6..37c3915 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/HighscoreGUI.java @@ -2,12 +2,21 @@ package de.hs_mannheim.informatik.pr2projekt.gui; import java.awt.BorderLayout; import java.awt.GridLayout; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Scanner; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain; + public class HighscoreGUI { public static void highscoreScreen(String[] filepath){ @@ -38,7 +47,7 @@ public class HighscoreGUI { "Hitori_Highscores/Hitori10x10medium.txt", "Hitori_Highscores/Hitori15x15_medium.txt" }; - showHighscores(paths[j]); + HighscoreGUI.showHighscores(paths[j]); frame.dispose(); }); } @@ -56,5 +65,73 @@ public class HighscoreGUI { frame.setDefaultCloseOperation(0); frame.add(highscorePanel); } + + public static void newRecord(String path, String username) throws FileNotFoundException{ + String[] parts = path.split("/"); + String filename = parts[parts.length - 1]; + int dotIndex = filename.lastIndexOf("."); + String result = filename.substring(0, dotIndex); + String ordner = "Hitori_Highscores/"; + String filetype = ".txt"; + String filepath = ordner+result+filetype; + Scanner sc = new Scanner(filepath); + while (sc.hasNextLine()) { + sc.nextLine(); + } + sc.close(); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(filepath, true))) { + writer.write(username); + writer.newLine(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void showHighscores(String[] filepath, String path){ + JFrame frame = new JFrame("Highscore"); + JPanel mainPanel = new JPanel(new BorderLayout()); + File file = new File(path); + int i = 0; + try (Scanner scanner = new Scanner(file)) { + while (scanner.hasNextLine()) { + scanner.nextLine(); + i++; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + JPanel highscorePanel = new JPanel(new GridLayout(i,1,10,10)); + if(i>0){ + ArrayList lines = HitoriMain.readFromFile(path); + for(String s: lines){ + JLabel text = new JLabel(s); + highscorePanel.add(text); + } + JButton b = new JButton("Zurück"); + b.addActionListener(e -> { + frame.dispose(); + highscoreScreen(filepath); + }); + mainPanel.add(b, BorderLayout.SOUTH); + } else { + JLabel text = new JLabel("Noch kein Highscore eingetragen."); + highscorePanel.add(text); + JButton b = new JButton("Zurück"); + b.addActionListener(e -> { + frame.dispose(); + highscoreScreen(filepath); + }); + mainPanel.add(b, BorderLayout.SOUTH); + } + JButton b = new JButton("Zurück"); + b.addActionListener(e ->{ + frame.dispose(); + MenuGUI.getPath(filepath); + }); + mainPanel.add(highscorePanel, BorderLayout.CENTER); + frame.add(mainPanel); + frame.setVisible(true); + frame.setSize(600,600); + } } diff --git a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java index ea98b17..530ba66 100644 --- a/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java +++ b/PR2Projekt/src/de/hs_mannheim/informatik/pr2projekt/gui/MenuGUI.java @@ -51,7 +51,7 @@ public class MenuGUI { } JButton b = new JButton("Highscores"); b.addActionListener(e -> { - HighscoreGUI.highscoreScreen(); + HighscoreGUI.highscoreScreen(filepath); frame.dispose(); }); buttonPanel.add(b);