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,14 +24,19 @@ 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 {
|
||||||
|
|
||||||
|
|
@ -78,39 +83,23 @@ public class SpielFrame extends JFrame {
|
||||||
|
|
||||||
// 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
|
|
||||||
JLabel clock1 = clock.getClock2();
|
|
||||||
panelRechts.add(clock1);
|
|
||||||
|
|
||||||
contentPane.add(Box.createVerticalStrut(15));
|
|
||||||
|
|
||||||
JLabel pl2 = new JLabel("Player 2:");
|
|
||||||
pl2.setFont(new Font("Calibri", Font.BOLD, 35));
|
|
||||||
pl2.setForeground(Color.BLACK);
|
|
||||||
pl2.setAlignmentX(Component.LEFT_ALIGNMENT);
|
|
||||||
panelRechts.add(pl2);
|
|
||||||
|
|
||||||
//Zeitangabe Player2
|
|
||||||
JLabel clock2 = clock.getClock1();
|
|
||||||
panelRechts.add(clock2);
|
|
||||||
|
|
||||||
// JSplitPane horizontal (linke und rechte Hälfte)
|
// JSplitPane horizontal (linke und rechte Hälfte)
|
||||||
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLinks, panelRechts);
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLinks, panelRechts);
|
||||||
splitPane.setResizeWeight(0.65);
|
splitPane.setResizeWeight(0.75);
|
||||||
splitPane.setBackground(Color.BLACK);
|
splitPane.setBackground(Color.BLACK);
|
||||||
splitPane.setDividerSize(0);
|
splitPane.setDividerSize(1);
|
||||||
splitPane.setEnabled(false);
|
splitPane.setEnabled(false);
|
||||||
|
|
||||||
contentPane.add(splitPane, BorderLayout.CENTER);
|
contentPane.add(splitPane, BorderLayout.CENTER);
|
||||||
|
|
@ -214,10 +203,10 @@ public class SpielFrame extends JFrame {
|
||||||
for (int i = 0; i < 64; i++) {
|
for (int i = 0; i < 64; i++) {
|
||||||
JButton b = buttons.get(i);
|
JButton b = buttons.get(i);
|
||||||
if ((i / 8 + i % 8) % 2 == 0) {
|
if ((i / 8 + i % 8) % 2 == 0) {
|
||||||
//logger.info("Helles Feld erstellt." + i);
|
// logger.info("Helles Feld erstellt." + i);
|
||||||
b.setBackground(new Color(90, 90, 90));
|
b.setBackground(new Color(90, 90, 90));
|
||||||
} else {
|
} else {
|
||||||
//logger.info("Dunkles Feld erstellt." + i);
|
// logger.info("Dunkles Feld erstellt." + i);
|
||||||
b.setBackground(new Color(65, 65, 65));
|
b.setBackground(new Color(65, 65, 65));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -304,4 +293,187 @@ public class SpielFrame extends JFrame {
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JPanel getUiPlayerTwo() {
|
||||||
|
|
||||||
|
JPanel playerTwo = new JPanel();
|
||||||
|
playerTwo.setBackground(new Color(90, 90, 90));
|
||||||
|
playerTwo.setLayout(new BoxLayout(playerTwo, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
playerTwo.add(Box.createVerticalStrut(15));
|
||||||
|
|
||||||
|
JLabel pl2 = new JLabel("Player 2:");
|
||||||
|
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);
|
||||||
|
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