From 907772d80cb0f46b187f2165c683dd83af9cb5a1 Mon Sep 17 00:00:00 2001 From: <3020511@stud.hs-mannheim.de> Date: Tue, 10 Jun 2025 16:29:06 +0200 Subject: [PATCH] =?UTF-8?q?Kleine=20=C3=84nderungen=20an=20der=20Schachuhr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/de/mannheim/th/chess/utl/Clock.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/mannheim/th/chess/utl/Clock.java b/src/main/java/de/mannheim/th/chess/utl/Clock.java index 3fdd556..7c90dab 100644 --- a/src/main/java/de/mannheim/th/chess/utl/Clock.java +++ b/src/main/java/de/mannheim/th/chess/utl/Clock.java @@ -11,6 +11,8 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.Timer; @@ -34,29 +36,29 @@ public class Clock extends Thread implements Runnable { public void run() { JFrame clockFrame = new JFrame("Clock"); - Container pane = clockFrame.getContentPane(); - pane.setBackground(Color.BLACK); + + JPanel player1Panel = new JPanel(); + player1Panel.setBackground(Color.BLACK); + JPanel player2Panel = new JPanel(); + player2Panel.setBackground(Color.BLACK); clockFrame.setBounds(1000, 500, 10000, 10000); - clockFrame.setBackground(Color.BLACK); clockFrame.setLayout(new BorderLayout()); - var clock1 = new JLabel(minutes + ":00"); + JLabel clock1 = new JLabel(" " + minutes + ":00 "); clock1.setForeground(Color.WHITE); clock1.setFont(new Font("Arial", Font.BOLD, 50)); - var clock2 = new JLabel(minutes + ":00"); - clock2.setFont(new Font("Arial", Font.BOLD, 50)); + JLabel clock2 = new JLabel(" " + minutes + ":00 "); clock2.setForeground(Color.WHITE); - var middleSpace = new JTextArea(" "); - middleSpace.setBackground(Color.BLACK); - middleSpace.setEditable(false); - pane.add(middleSpace, BorderLayout.CENTER); + clock2.setFont(new Font("Arial", Font.BOLD, 50)); + player1Panel.add(clock1); + player2Panel.add(clock2); + JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, player1Panel, player2Panel); + split.setFont(new Font("Arial", Font.BOLD, 50)); + clockFrame.add(split); var min1 = new AtomicInteger(minutes); var sec1 = new AtomicInteger(0); var min2 = new AtomicInteger(minutes); var sec2 = new AtomicInteger(0); - pane.add(clock1, BorderLayout.LINE_START); - pane.add(middleSpace, BorderLayout.CENTER); - pane.add(clock2, BorderLayout.LINE_END); clockFrame.pack(); clockFrame.setVisible(true);