Anzeige neben Spielbrett verschönert
parent
593b0e9fbe
commit
fb40f3019b
|
|
@ -170,4 +170,8 @@ public class Game {
|
||||||
public Clock getClock() {
|
public Clock getClock() {
|
||||||
return this.clock;
|
return this.clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isZuruecknahme() {
|
||||||
|
return zuruecknahme;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,284 +24,456 @@ import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
public class SpielFrame extends JFrame {
|
public class SpielFrame extends JFrame {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(App.class);
|
private static final Logger logger = LogManager.getLogger(App.class);
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private ArrayList<JButton> buttons = new ArrayList<>();
|
private ArrayList<JButton> buttons = new ArrayList<>();
|
||||||
private HashMap<JButton, String> belegungen = new HashMap<>();
|
private HashMap<JButton, String> belegungen = new HashMap<>();
|
||||||
private JPanel panelLinks, panelRechts, contentPane;
|
private JPanel panelLinks, panelRechts, contentPane;
|
||||||
private Game game;
|
private Game game;
|
||||||
private Clock clock;
|
private Clock clock;
|
||||||
|
|
||||||
private BoardMode mode;
|
private BoardMode mode;
|
||||||
private Square selectedSquare;
|
private Square selectedSquare;
|
||||||
|
|
||||||
public enum BoardMode {
|
public enum BoardMode {
|
||||||
normal, pieceSelected, finished
|
normal, pieceSelected, finished
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public SpielFrame(Game game) {
|
public SpielFrame(Game game) {
|
||||||
|
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.clock = game.getClock();
|
this.clock = game.getClock();
|
||||||
this.clock.start();
|
this.clock.start();
|
||||||
|
|
||||||
mode = BoardMode.normal;
|
mode = BoardMode.normal;
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 1920, 1080);
|
setBounds(100, 100, 1920, 1080);
|
||||||
setTitle("Schach");
|
setTitle("Schach");
|
||||||
setAlwaysOnTop(true);
|
setAlwaysOnTop(true);
|
||||||
|
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setLayout(new BorderLayout());
|
contentPane.setLayout(new BorderLayout());
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
|
|
||||||
// Linkes Panel mit GridLayout 8x8 für Schachbrett
|
// Linkes Panel mit GridLayout 8x8 für Schachbrett
|
||||||
panelLinks = new JPanel(new GridLayout(8, 8));
|
panelLinks = new JPanel(new GridLayout(8, 8));
|
||||||
|
|
||||||
erstelleBrett();
|
erstelleBrett();
|
||||||
|
|
||||||
// Rechtes Panel für Steuerung oder zusätzliche Eingaben
|
// Rechtes Panel für Steuerung oder zusätzliche Eingaben
|
||||||
panelRechts = new JPanel();
|
panelRechts = new JPanel();
|
||||||
panelRechts.setBackground(new Color(90,90,90));
|
panelRechts.setBackground(new Color(90, 90, 90));
|
||||||
panelRechts.setLayout(new BoxLayout(panelRechts, BoxLayout.Y_AXIS));
|
panelRechts.setLayout(new BoxLayout(panelRechts, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
// Panel für alle Eingaben von Player 2
|
||||||
|
panelRechts.add(getUiPlayerTwo());
|
||||||
|
|
||||||
JLabel pl1 = new JLabel("Player 1:");
|
// Panel für Statistikanzeigen
|
||||||
pl1.setFont(new Font("Calibri", Font.BOLD, 35));
|
panelRechts.add(getUiStatistik());
|
||||||
pl1.setForeground(Color.BLACK);
|
|
||||||
pl1.setAlignmentX(Component.LEFT_ALIGNMENT);
|
|
||||||
panelRechts.add(pl1);
|
|
||||||
|
|
||||||
contentPane.add(Box.createVerticalStrut(15));
|
//Panel für alle Eingaben von Player 1
|
||||||
|
panelRechts.add(getUiPlayerOne());
|
||||||
|
|
||||||
//Zeitangabe Player1
|
// JSplitPane horizontal (linke und rechte Hälfte)
|
||||||
JLabel clock1 = clock.getClock2();
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLinks, panelRechts);
|
||||||
panelRechts.add(clock1);
|
splitPane.setResizeWeight(0.75);
|
||||||
|
splitPane.setBackground(Color.BLACK);
|
||||||
|
splitPane.setDividerSize(1);
|
||||||
|
splitPane.setEnabled(false);
|
||||||
|
|
||||||
contentPane.add(Box.createVerticalStrut(15));
|
contentPane.add(splitPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
JLabel pl2 = new JLabel("Player 2:");
|
setVisible(true);
|
||||||
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
}
|
||||||
pl2.setForeground(Color.BLACK);
|
|
||||||
pl2.setAlignmentX(Component.LEFT_ALIGNMENT);
|
|
||||||
panelRechts.add(pl2);
|
|
||||||
|
|
||||||
//Zeitangabe Player2
|
public void setBoardMode(BoardMode bm) {
|
||||||
JLabel clock2 = clock.getClock1();
|
this.mode = bm;
|
||||||
panelRechts.add(clock2);
|
}
|
||||||
|
|
||||||
// JSplitPane horizontal (linke und rechte Hälfte)
|
public void setSelectedSquare(Square sq) {
|
||||||
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLinks, panelRechts);
|
this.selectedSquare = sq;
|
||||||
splitPane.setResizeWeight(0.65);
|
}
|
||||||
splitPane.setBackground(Color.BLACK);
|
|
||||||
splitPane.setDividerSize(0);
|
|
||||||
splitPane.setEnabled(false);
|
|
||||||
|
|
||||||
contentPane.add(splitPane, BorderLayout.CENTER);
|
public HashMap<JButton, String> getBelegung() {
|
||||||
|
return this.belegungen;
|
||||||
|
}
|
||||||
|
|
||||||
setVisible(true);
|
/**
|
||||||
}
|
* Erstellt alle Buttons und fügt sie dem Frame hinzu.
|
||||||
|
*/
|
||||||
|
public void erstelleBrett() {
|
||||||
|
|
||||||
public void setBoardMode(BoardMode bm) {
|
this.clearButtons();
|
||||||
this.mode = bm;
|
this.setDefaultBackground();
|
||||||
}
|
this.setButtonsActions();
|
||||||
|
|
||||||
public void setSelectedSquare(Square sq) {
|
ladeBrett();
|
||||||
this.selectedSquare = sq;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<JButton, String> getBelegung() {
|
panelLinks.revalidate();
|
||||||
return this.belegungen;
|
panelLinks.repaint();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* Erstellt alle Buttons und fügt sie dem Frame hinzu.
|
|
||||||
*/
|
|
||||||
public void erstelleBrett() {
|
|
||||||
|
|
||||||
this.clearButtons();
|
private int mirrowedGrid(int i) {
|
||||||
this.setDefaultBackground();
|
return 63 - (((i / 8) * 8) + (7 - i % 8));
|
||||||
this.setButtonsActions();
|
}
|
||||||
|
|
||||||
ladeBrett();
|
/**
|
||||||
|
* holt sich FEN-Zeichenkette und extrahiert daraus die Positionen der Figuren
|
||||||
|
*/
|
||||||
|
private void ladeBrett() {
|
||||||
|
// System.out.println(game.toFEN());
|
||||||
|
|
||||||
panelLinks.revalidate();
|
char[] fen = game.toFEN().replaceAll("/", "").split(" ")[0].toCharArray();
|
||||||
panelLinks.repaint();
|
int i = 0;
|
||||||
|
for (int j = 0; j < fen.length; j++) {
|
||||||
|
if (Character.isDigit(fen[j])) {
|
||||||
|
int leerfelder = Character.getNumericValue(fen[j]);
|
||||||
|
for (int k = 0; k < leerfelder; k++) {
|
||||||
|
belegungen.put(buttons.get(i), "n-n");
|
||||||
|
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, weil leere Felder
|
||||||
|
// nicht ckickbar sein sollten.
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
} else if (fen[j] >= 65 && fen[j] <= 90) { // ein Großbuchstabe, also
|
||||||
|
belegungen.put(buttons.get(i), "w-" + fen[j]);
|
||||||
|
} else if (fen[j] >= 97 && fen[j] <= 122) { // ein Kleinbuchstabe, also
|
||||||
|
belegungen.put(buttons.get(i), "b-" + fen[j]);
|
||||||
|
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, damit weiß
|
||||||
|
// beginnen kann
|
||||||
|
}
|
||||||
|
buttons.get(i).setIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
||||||
|
buttons.get(i).setDisabledIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
||||||
|
|
||||||
}
|
i++;
|
||||||
|
|
||||||
private int mirrowedGrid(int i) {
|
}
|
||||||
return 63 - (((i / 8) * 8) + (7 - i % 8));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holt sich FEN-Zeichenkette und extrahiert daraus die Positionen der Figuren
|
* Clears the existing buttons from the button list, panellinks and fills them
|
||||||
*/
|
* with new blank ones.
|
||||||
private void ladeBrett() {
|
*/
|
||||||
// System.out.println(game.toFEN());
|
private void clearButtons() {
|
||||||
|
buttons.clear();
|
||||||
|
panelLinks.removeAll();
|
||||||
|
|
||||||
char[] fen = game.toFEN().replaceAll("/", "").split(" ")[0].toCharArray();
|
for (int i = 0; i < 64; i++) {
|
||||||
int i = 0;
|
JButton b = new JButton();
|
||||||
for (int j = 0; j < fen.length; j++) {
|
|
||||||
if (Character.isDigit(fen[j])) {
|
|
||||||
int leerfelder = Character.getNumericValue(fen[j]);
|
|
||||||
for (int k = 0; k < leerfelder; k++) {
|
|
||||||
belegungen.put(buttons.get(i), "n-n");
|
|
||||||
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, weil leere Felder
|
|
||||||
// nicht ckickbar sein sollten.
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
} else if (fen[j] >= 65 && fen[j] <= 90) { // ein Großbuchstabe, also
|
|
||||||
belegungen.put(buttons.get(i), "w-" + fen[j]);
|
|
||||||
} else if (fen[j] >= 97 && fen[j] <= 122) { // ein Kleinbuchstabe, also
|
|
||||||
belegungen.put(buttons.get(i), "b-" + fen[j]);
|
|
||||||
// buttons.get(i).setEnabled(false); // erstmal deaktivieren, damit weiß
|
|
||||||
// beginnen kann
|
|
||||||
}
|
|
||||||
buttons.get(i).setIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
|
||||||
buttons.get(i).setDisabledIcon(new ImageIcon("src/main/resources/" + (int) fen[j] + ".png"));
|
|
||||||
|
|
||||||
i++;
|
b.setEnabled(false);
|
||||||
|
|
||||||
}
|
// style
|
||||||
}
|
b.setFocusPainted(false);
|
||||||
|
b.setFont(new Font("Arial", Font.PLAIN, 30));
|
||||||
|
b.setForeground(Color.WHITE);
|
||||||
|
b.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||||
|
b.setName(i + "");
|
||||||
|
|
||||||
/**
|
buttons.add(b);
|
||||||
* Clears the existing buttons from the button list, panellinks and fills them
|
}
|
||||||
* with new blank ones.
|
}
|
||||||
*/
|
|
||||||
private void clearButtons() {
|
|
||||||
buttons.clear();
|
|
||||||
panelLinks.removeAll();
|
|
||||||
|
|
||||||
for (int i = 0; i < 64; i++) {
|
/**
|
||||||
JButton b = new JButton();
|
* Sets the default background color for the buttons in the grid.
|
||||||
|
*/
|
||||||
|
private void setDefaultBackground() {
|
||||||
|
for (int i = 0; i < 64; i++) {
|
||||||
|
JButton b = buttons.get(i);
|
||||||
|
if ((i / 8 + i % 8) % 2 == 0) {
|
||||||
|
// logger.info("Helles Feld erstellt." + i);
|
||||||
|
b.setBackground(new Color(90, 90, 90));
|
||||||
|
} else {
|
||||||
|
// logger.info("Dunkles Feld erstellt." + i);
|
||||||
|
b.setBackground(new Color(65, 65, 65));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
b.setEnabled(false);
|
/*
|
||||||
|
* Switches the button actions depending on the boardmode
|
||||||
|
*/
|
||||||
|
private void setButtonsActions() {
|
||||||
|
|
||||||
// style
|
List<Square> selectables;
|
||||||
b.setFocusPainted(false);
|
|
||||||
b.setFont(new Font("Arial", Font.PLAIN, 30));
|
|
||||||
b.setForeground(Color.WHITE);
|
|
||||||
b.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
|
||||||
b.setName(i + "");
|
|
||||||
|
|
||||||
buttons.add(b);
|
switch (this.mode) {
|
||||||
}
|
case BoardMode.normal:
|
||||||
}
|
selectables = game.getAllLegalMoveableSquares();
|
||||||
|
|
||||||
/**
|
for (Square square : selectables) {
|
||||||
* Sets the default background color for the buttons in the grid.
|
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
||||||
*/
|
b.setEnabled(true);
|
||||||
private void setDefaultBackground() {
|
// b.setBackground(Color.green);
|
||||||
for (int i = 0; i < 64; i++) {
|
b.addActionListener(new ButtonSelectPieceListener(this, square));
|
||||||
JButton b = buttons.get(i);
|
}
|
||||||
if ((i / 8 + i % 8) % 2 == 0) {
|
|
||||||
//logger.info("Helles Feld erstellt." + i);
|
|
||||||
b.setBackground(new Color(90, 90, 90));
|
|
||||||
} else {
|
|
||||||
//logger.info("Dunkles Feld erstellt." + i);
|
|
||||||
b.setBackground(new Color(65, 65, 65));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
break;
|
||||||
* Switches the button actions depending on the boardmode
|
|
||||||
*/
|
|
||||||
private void setButtonsActions() {
|
|
||||||
|
|
||||||
List<Square> selectables;
|
case BoardMode.pieceSelected:
|
||||||
|
|
||||||
switch (this.mode) {
|
JButton s = buttons.get(mirrowedGrid(selectedSquare.ordinal()));
|
||||||
case BoardMode.normal:
|
s.setEnabled(true);
|
||||||
selectables = game.getAllLegalMoveableSquares();
|
s.setBackground(new Color(165, 42, 42));
|
||||||
|
s.addActionListener(new ButtonToNormalListener(this)); // cancel action
|
||||||
|
|
||||||
for (Square square : selectables) {
|
selectables = game.getLegalMoveableSquares(selectedSquare);
|
||||||
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
|
||||||
b.setEnabled(true);
|
|
||||||
// b.setBackground(Color.green);
|
|
||||||
b.addActionListener(new ButtonSelectPieceListener(this, square));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
for (
|
||||||
|
|
||||||
case BoardMode.pieceSelected:
|
Square square : selectables) {
|
||||||
|
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
||||||
|
final Move move = new Move(selectedSquare, square);
|
||||||
|
b.setEnabled(true);
|
||||||
|
b.setBackground(new Color(230, 100, 100));
|
||||||
|
b.addActionListener(new ButtonMovePieceListener(this, this.game, move));
|
||||||
|
}
|
||||||
|
|
||||||
JButton s = buttons.get(mirrowedGrid(selectedSquare.ordinal()));
|
break;
|
||||||
s.setEnabled(true);
|
|
||||||
s.setBackground(new Color(165, 42, 42));
|
|
||||||
s.addActionListener(new ButtonToNormalListener(this)); // cancel action
|
|
||||||
|
|
||||||
selectables = game.getLegalMoveableSquares(selectedSquare);
|
case finished:
|
||||||
|
clearButtons();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
for (
|
}
|
||||||
|
|
||||||
Square square : selectables) {
|
for (JButton b : buttons) {
|
||||||
JButton b = buttons.get(mirrowedGrid(square.ordinal()));
|
panelLinks.add(b);
|
||||||
final Move move = new Move(selectedSquare, square);
|
}
|
||||||
b.setEnabled(true);
|
}
|
||||||
b.setBackground(new Color(230, 100, 100));
|
|
||||||
b.addActionListener(new ButtonMovePieceListener(this, this.game, move));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
public void showDraw() {
|
||||||
|
JFrame frame = new JFrame("Result");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setSize(300, 150);
|
||||||
|
frame.setLayout(null);
|
||||||
|
|
||||||
case finished:
|
JLabel jl = new JLabel("1/2 - 1/2");
|
||||||
clearButtons();
|
jl.setBounds(50, 30, 200, 25);
|
||||||
break;
|
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
||||||
default:
|
frame.add(jl);
|
||||||
break;
|
frame.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JButton b : buttons) {
|
public void showWin(int player) {
|
||||||
panelLinks.add(b);
|
JFrame frame = new JFrame("Result");
|
||||||
}
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
}
|
frame.setSize(300, 150);
|
||||||
|
frame.setLayout(null);
|
||||||
|
|
||||||
public void showDraw() {
|
JLabel jl = new JLabel(String.format("%d - %d", player / 2, player % 2));
|
||||||
JFrame frame = new JFrame("Result");
|
jl.setBounds(50, 30, 200, 25);
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
||||||
frame.setSize(300, 150);
|
frame.add(jl);
|
||||||
frame.setLayout(null);
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
JLabel jl = new JLabel("1/2 - 1/2");
|
private JPanel getUiPlayerTwo() {
|
||||||
jl.setBounds(50, 30, 200, 25);
|
|
||||||
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
|
||||||
frame.add(jl);
|
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
}
|
JPanel playerTwo = new JPanel();
|
||||||
|
playerTwo.setBackground(new Color(90, 90, 90));
|
||||||
|
playerTwo.setLayout(new BoxLayout(playerTwo, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
public void showWin(int player) {
|
playerTwo.add(Box.createVerticalStrut(15));
|
||||||
JFrame frame = new JFrame("Result");
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setSize(300, 150);
|
|
||||||
frame.setLayout(null);
|
|
||||||
|
|
||||||
JLabel jl = new JLabel(String.format("%d - %d", player / 2, player % 2));
|
JLabel pl2 = new JLabel("Player 2:");
|
||||||
jl.setBounds(50, 30, 200, 25);
|
pl2.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
|
||||||
jl.setFont(new Font("Tahoma", Font.BOLD, 20));
|
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
||||||
frame.add(jl);
|
pl2.setForeground(Color.BLACK);
|
||||||
frame.setVisible(true);
|
pl2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
}
|
playerTwo.add(pl2);
|
||||||
|
|
||||||
|
playerTwo.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
|
JLabel clock1 = clock.getClock2();
|
||||||
|
playerTwo.add(clock1);
|
||||||
|
|
||||||
|
playerTwo.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
|
// Button zurücknahme und aufgeben für Player 2
|
||||||
|
JPanel aufgebenUndo = new JPanel();
|
||||||
|
aufgebenUndo.setBackground(new Color(90, 90, 90));
|
||||||
|
aufgebenUndo.setLayout(new BoxLayout(aufgebenUndo, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
if (game.isZuruecknahme()) {
|
||||||
|
JButton undo = new JButton("Zug zurücknehmen");
|
||||||
|
undo.setBackground(Color.LIGHT_GRAY);
|
||||||
|
undo.setForeground(Color.BLACK);
|
||||||
|
undo.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
undo.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(undo);
|
||||||
|
|
||||||
|
// Button-Listener
|
||||||
|
undo.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
|
JButton aufgeben = new JButton("Aufgeben");
|
||||||
|
aufgeben.setBackground(Color.LIGHT_GRAY);
|
||||||
|
aufgeben.setForeground(Color.BLACK);
|
||||||
|
aufgeben.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
aufgeben.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(aufgeben);
|
||||||
|
|
||||||
|
// Button-Listener
|
||||||
|
aufgeben.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
|
JButton safe = new JButton("Spielstand sichern");
|
||||||
|
safe.setBackground(Color.LIGHT_GRAY);
|
||||||
|
safe.setForeground(Color.BLACK);
|
||||||
|
safe.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
safe.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(safe);
|
||||||
|
|
||||||
|
// Button-Listener
|
||||||
|
safe.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
playerTwo.add(aufgebenUndo);
|
||||||
|
|
||||||
|
playerTwo.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
|
return playerTwo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel getUiStatistik() {
|
||||||
|
|
||||||
|
JPanel statistik = new JPanel();
|
||||||
|
statistik.setBackground(new Color(90, 90, 90));
|
||||||
|
statistik.setLayout(new BoxLayout(statistik, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
JTextArea ausgabe = new JTextArea();
|
||||||
|
ausgabe.setEditable(false);
|
||||||
|
ausgabe.setBackground(new Color(75,75,75));
|
||||||
|
ausgabe.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
|
statistik.add(ausgabe);
|
||||||
|
return statistik;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel getUiPlayerOne() {
|
||||||
|
|
||||||
|
JPanel playerOne = new JPanel();
|
||||||
|
playerOne.setBackground(new Color(90, 90, 90));
|
||||||
|
playerOne.setLayout(new BoxLayout(playerOne, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
playerOne.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
|
// Button zurücknahme und aufgeben für Player 1
|
||||||
|
JPanel aufgebenUndo = new JPanel();
|
||||||
|
aufgebenUndo.setBackground(new Color(90, 90, 90));
|
||||||
|
aufgebenUndo.setLayout(new BoxLayout(aufgebenUndo, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
if (game.isZuruecknahme()) {
|
||||||
|
JButton undo = new JButton("Zug zurücknehmen");
|
||||||
|
undo.setBackground(Color.LIGHT_GRAY);
|
||||||
|
undo.setForeground(Color.BLACK);
|
||||||
|
undo.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
undo.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(undo);
|
||||||
|
|
||||||
|
// Button-Listener
|
||||||
|
undo.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
|
JButton aufgeben = new JButton("Aufgeben");
|
||||||
|
aufgeben.setBackground(Color.LIGHT_GRAY);
|
||||||
|
aufgeben.setForeground(Color.BLACK);
|
||||||
|
aufgeben.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
aufgeben.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(aufgeben);
|
||||||
|
|
||||||
|
// Button-Listener
|
||||||
|
aufgeben.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
aufgebenUndo.add(Box.createHorizontalStrut(10));
|
||||||
|
|
||||||
|
JButton safe = new JButton("Spielstand sichern");
|
||||||
|
safe.setBackground(Color.LIGHT_GRAY);
|
||||||
|
safe.setForeground(Color.BLACK);
|
||||||
|
safe.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
|
safe.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
aufgebenUndo.add(safe);
|
||||||
|
|
||||||
|
// Button-Listener
|
||||||
|
safe.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
playerOne.add(aufgebenUndo);
|
||||||
|
|
||||||
|
playerOne.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
|
JLabel clock1 = clock.getClock1();
|
||||||
|
playerOne.add(clock1);
|
||||||
|
|
||||||
|
playerOne.add(Box.createVerticalStrut(10));
|
||||||
|
|
||||||
|
JLabel pl2 = new JLabel("Player 1:");
|
||||||
|
pl2.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
|
||||||
|
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
||||||
|
pl2.setForeground(Color.BLACK);
|
||||||
|
pl2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
playerOne.add(pl2);
|
||||||
|
|
||||||
|
return playerOne;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ package de.mannheim.th.chess.utl;
|
||||||
*/
|
*/
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
@ -54,12 +56,17 @@ public class Clock extends Thread implements Runnable {
|
||||||
// player2Panel.setBackground(Color.BLACK);
|
// player2Panel.setBackground(Color.BLACK);
|
||||||
// clockFrame.setBounds(1000, 500, 10000, 10000);
|
// clockFrame.setBounds(1000, 500, 10000, 10000);
|
||||||
// clockFrame.setLayout(new BorderLayout());
|
// clockFrame.setLayout(new BorderLayout());
|
||||||
clock1 = new JLabel(" " + minutes + ":00 ");
|
clock1 = new JLabel("" + minutes + ":00 ");
|
||||||
|
clock1.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0));
|
||||||
clock1.setForeground(Color.BLACK);
|
clock1.setForeground(Color.BLACK);
|
||||||
clock1.setFont(new Font("Calibri", Font.BOLD, 35));
|
clock1.setFont(new Font("Calibri", Font.BOLD, 35));
|
||||||
clock2 = new JLabel(" " + minutes + ":00 ");
|
clock1.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
|
||||||
|
clock2 = new JLabel("" + minutes + ":00 ");
|
||||||
|
clock2.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0));
|
||||||
clock2.setForeground(Color.BLACK);
|
clock2.setForeground(Color.BLACK);
|
||||||
clock2.setFont(new Font("Calibri", Font.BOLD, 35));
|
clock2.setFont(new Font("Calibri", Font.BOLD, 35));
|
||||||
|
clock2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
// player1Panel.add(clock1);
|
// player1Panel.add(clock1);
|
||||||
// player2Panel.add(clock2);
|
// player2Panel.add(clock2);
|
||||||
// JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, player1Panel, player2Panel);
|
// JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, player1Panel, player2Panel);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue