Added kontextText variations.

Added functionality to "Ready" Button.
This commit is contained in:
Joshua 2024-12-14 17:26:46 +01:00
parent 587d88f764
commit d3f5421808
2 changed files with 21 additions and 3 deletions

View File

@ -28,7 +28,7 @@ public class BoardDisplay extends JPanel {
this.ships = new ArrayList<>(); this.ships = new ArrayList<>();
this.player = player; this.player = player;
this.gridSize = gridSize; this.gridSize = gridSize;
System.out.println("Name in Boarddisplay: " + player.getName());//Testausgabe
// Erstellung von Spielfeld // Erstellung von Spielfeld
for (int i = 0; i <= gridSize; i++) { for (int i = 0; i <= gridSize; i++) {
for (int j = 0; j <= gridSize; j++) { for (int j = 0; j <= gridSize; j++) {

View File

@ -23,9 +23,19 @@ public class GameBoard extends JPanel {
ImageIcon gameBoardEmtpy = new ImageIcon("graphics/gameboardempty.png"); ImageIcon gameBoardEmtpy = new ImageIcon("graphics/gameboardempty.png");
ImageIcon gameBoardX = new ImageIcon("graphics/gameboardx.png"); ImageIcon gameBoardX = new ImageIcon("graphics/gameboardx.png");
// kontextText Text-Strings
String kT1 = "Bitte Schiffe setzten";
String kT2 = "Warte auf Gegner";
String kT3 = "Du fängst an";
String kT4 = "Dein Gegner fängt an";
String kT5 = "Du bist am Zug";
String kT6 = "Dein Gegner ist am Zug";
String kT7 = "Du hast das Spiel gewonnen";
String kT8 = "Du hast das Spiel verloren";
// Labels // Labels
JLabel frameTitle = new JLabel("GameBoard"); JLabel frameTitle = new JLabel("GameBoard");
JLabel kontextText = new JLabel("Bitte Schiffe setzten"); JLabel kontextText = new JLabel(kT1);
JButton backButton = new JButton(backButtonIcon); JButton backButton = new JButton(backButtonIcon);
// Eigene ModulButtons // Eigene ModulButtons
@ -143,6 +153,14 @@ public class GameBoard extends JPanel {
ownBoardPanel.resetAllShips(); ownBoardPanel.resetAllShips();
} }
}); });
rightPlayerModul7.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//TODO richtige funktion einfügen
kontextText.setText(kT2);
}
});
// Panel für die Buttons des rechten Spielers (ganz rechts) // Panel für die Buttons des rechten Spielers (ganz rechts)
//JPanel ownBoardPanel = new JPanel(new GridLayout(gridSize, gridSize)); //JPanel ownBoardPanel = new JPanel(new GridLayout(gridSize, gridSize));
@ -159,7 +177,7 @@ public class GameBoard extends JPanel {
playerNamesPanel.setLayout(new GridLayout(1, 2)); // Zwei Labels nebeneinander playerNamesPanel.setLayout(new GridLayout(1, 2)); // Zwei Labels nebeneinander
JLabel player1NameLabel = new JLabel(p1.getName(), SwingConstants.CENTER); JLabel player1NameLabel = new JLabel(p1.getName(), SwingConstants.CENTER);
JLabel player2NameLabel = new JLabel(p2.getName(), SwingConstants.CENTER); JLabel player2NameLabel = new JLabel(p2.getName(), SwingConstants.CENTER);
System.out.println(player2NameLabel.getText()); System.out.println("Name in Gameboard: " + player1NameLabel.getText());
// Schrift und Formatierung der Labels // Schrift und Formatierung der Labels
player1NameLabel.setFont(new Font("Roboto", Font.BOLD, 18)); player1NameLabel.setFont(new Font("Roboto", Font.BOLD, 18));