added main menu to menugui class

gui
beratkocak 2024-12-20 13:45:39 +01:00
parent 1665072cfa
commit 093c9bf601
2 changed files with 67 additions and 2 deletions

View File

@ -2,4 +2,9 @@ package de.hs_mannheim.informatik.pr2projekt.gui;
public class HighscoreGUI {
public static void highscoreScreen() {
// TODO Auto-generated method stub
}
}

View File

@ -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<buttons.length;i++){
JButton b0 = new JButton(buttons[i]);
buttonPanel.add(b0);
int[] count = {i};
char rowChar = buttons[i].charAt(0);
String[] row = {String.valueOf(rowChar)};
b0.addActionListener(e -> {
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);
}
}