Removed unused buttons in MainGui
parent
d1feea3fe5
commit
bfbb878647
|
@ -1,15 +1,19 @@
|
|||
package de.hs_mannheim.informatik.chess.view;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class MainGui {
|
||||
|
||||
private JFrame frame;
|
||||
private Runnable onStartGame;
|
||||
|
||||
public MainGui(Runnable onStartGame) {
|
||||
this.onStartGame = onStartGame;
|
||||
JButton btnMode1 = new JButton("Normal Mode");
|
||||
JButton btnCreative = new JButton("Creative Mode");
|
||||
JButton btnLoadGame = new JButton("Load Game (PGN)");
|
||||
|
||||
public MainGui() {
|
||||
|
||||
frame = new JFrame("Chess - Hauptmenü");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
@ -38,44 +42,32 @@ public class MainGui {
|
|||
gbc.ipady = 15;
|
||||
mainPanel.add(Box.createRigidArea(new Dimension(0, 20)), gbc);
|
||||
|
||||
//Buttons
|
||||
JButton btnMode1 = new JButton("Normal Mode");
|
||||
JButton btnMode2 = new JButton("Mode 2 (coming soon)");
|
||||
JButton btnMode3 = new JButton("Mode 3 (coming soon)");
|
||||
JButton btnCreative = new JButton("Creative Mode");
|
||||
JButton btnLoadGame = new JButton("Load Game (PGN)");
|
||||
|
||||
styleButton(btnMode1);
|
||||
styleButton(btnMode2);
|
||||
styleButton(btnMode3);
|
||||
styleButton(btnCreative);
|
||||
styleButton(btnLoadGame);
|
||||
|
||||
gbc.gridy = 2; gbc.ipady = 25;
|
||||
gbc.gridy = 1; gbc.ipady = 25;
|
||||
mainPanel.add(btnMode1, gbc);
|
||||
|
||||
gbc.gridy = 3;
|
||||
mainPanel.add(btnMode2, gbc);
|
||||
|
||||
gbc.gridy = 4;
|
||||
mainPanel.add(btnMode3, gbc);
|
||||
|
||||
gbc.gridy = 5;
|
||||
gbc.gridy = 2;
|
||||
mainPanel.add(btnCreative, gbc);
|
||||
|
||||
gbc.gridy = 6;
|
||||
gbc.gridy = 3;
|
||||
mainPanel.add(btnLoadGame, gbc);
|
||||
|
||||
frame.add(mainPanel);
|
||||
frame.setVisible(true);
|
||||
|
||||
//Button ActionListener für "Normal Modus"
|
||||
btnMode1.addActionListener(e -> {
|
||||
frame.dispose(); // Hauptmenü schließen
|
||||
onStartGame.run(); // **Ruft den Callback auf**
|
||||
});
|
||||
}
|
||||
// --- Methoden für Controller zum Setzen der Listener ---
|
||||
public void setNormalModeListener(ActionListener l) { btnMode1.addActionListener(l); }
|
||||
public void setCreativeModeListener(ActionListener l) { btnCreative.addActionListener(l); }
|
||||
public void setLoadGameListener(ActionListener l) { btnLoadGame.addActionListener(l); }
|
||||
|
||||
public void close() {
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
// Helper für Button Styling
|
||||
private void styleButton(JButton btn) {
|
||||
btn.setFont(new Font("Serif", Font.BOLD, 30));
|
||||
|
|
Loading…
Reference in New Issue