From d5d6af193e886d31ddcba08b50dfbe95c7915e15 Mon Sep 17 00:00:00 2001 From: Lorenz Hohmann Date: Mon, 17 Jan 2022 15:38:43 +0100 Subject: [PATCH] Beautified GUI Won Screen --- .../java/de/tims/fleetstorm/gui/GameLogic.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/de/tims/fleetstorm/gui/GameLogic.java b/src/main/java/de/tims/fleetstorm/gui/GameLogic.java index 04c82ee..2bc34d5 100644 --- a/src/main/java/de/tims/fleetstorm/gui/GameLogic.java +++ b/src/main/java/de/tims/fleetstorm/gui/GameLogic.java @@ -1,6 +1,8 @@ package de.tims.fleetstorm.gui; +import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Font; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -8,6 +10,7 @@ import java.util.ArrayList; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.SwingConstants; import javax.swing.border.MatteBorder; import de.tims.fleetstorm.ai.Logic; @@ -245,6 +248,18 @@ public class GameLogic extends JPanel { protected void gameOver(boolean playerWinner) { this.gameState = GameLogic.GAME_OVER; + + this.removeAll(); + this.setLayout(new BorderLayout()); + + JLabel wonLabel = new JLabel(playerWinner ? "Du hast gewonnen!" : "Du hast verloren!"); + wonLabel.setHorizontalAlignment(SwingConstants.CENTER); + wonLabel.setVerticalAlignment(SwingConstants.CENTER); + wonLabel.setFont(new Font("Tahoma", Font.BOLD, 18)); + this.add(wonLabel, SwingConstants.CENTER); + + this.revalidate(); + this.repaint(); } public int getGameState() {