From d1c2f9e7a4256be928c5f52ce26c942f17e84b43 Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Wed, 7 Feb 2024 20:23:02 +0100 Subject: [PATCH] Refactor: move window dimensions to a new Constants class --- src/main/java/ChatClient.java | 4 +--- src/main/java/Constants.java | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 src/main/java/Constants.java diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index fbc9b4e..0e2cf51 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -6,8 +6,6 @@ import java.io.*; import java.net.Socket; public class ChatClient extends JFrame implements KeyListener { - private static final int WINDOW_WIDTH = 800; - private static final int WINDOW_HEIGHT = 600; private String address; private int port; private Socket connectionToServer; @@ -44,7 +42,7 @@ public class ChatClient extends JFrame implements KeyListener { add(inputTextField, BorderLayout.SOUTH); setVisible(true); - setSize(WINDOW_WIDTH, WINDOW_HEIGHT); + setSize(Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); } diff --git a/src/main/java/Constants.java b/src/main/java/Constants.java new file mode 100644 index 0000000..15a8e91 --- /dev/null +++ b/src/main/java/Constants.java @@ -0,0 +1,4 @@ +public class Constants { + public static final int WINDOW_WIDTH = 800; + public static final int WINDOW_HEIGHT = 600; +}