From 4ed49f7d4bd1e2b0363d38b04f0c9c272989659f Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 02:30:54 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Kommentare=20und=20=C3=9Cbersich?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 4340cd3..de20bd9 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -16,14 +16,19 @@ import javax.swing.JTextField; public class ChatGUI implements ActionListener { + // Menu items for font sizes JMenuItem small = new JMenuItem("small-font"); JMenuItem medium = new JMenuItem("medium-font"); JMenuItem large = new JMenuItem("large-font"); - JMenuItem exit = new JMenuItem("Exit"); + + // Menu items for font colors JMenuItem black = new JMenuItem("black"); JMenuItem red = new JMenuItem("red"); JMenuItem blue = new JMenuItem("blue"); JMenuItem green = new JMenuItem("green"); + + JMenuItem exit = new JMenuItem("Exit"); + JTextField inputTextField = new JTextField(); JTextArea outputTextArea = new JTextArea(); @@ -35,12 +40,13 @@ public class ChatGUI implements ActionListener { // Set up the main frame gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setTitle("java-chat"); - gui.setLayout(new BorderLayout()); - + + // Set up the menu bar JMenuBar bar = new JMenuBar(); gui.setJMenuBar(bar); - + + // Create menu items and menus JMenu options = new JMenu("options"); JMenu colors = new JMenu("font-colors"); JMenu size = new JMenu("font-size"); @@ -60,7 +66,8 @@ public class ChatGUI implements ActionListener { size.add(small); size.add(medium); size.add(large); - + + // Register action listeners for menu items red.addActionListener(this); blue.addActionListener(this); black.addActionListener(this); @@ -90,7 +97,7 @@ public class ChatGUI implements ActionListener { gui.setSize(quarterWidth, quarterHeight); gui.setVisible(true); } - + // main methode zum Testen, müsste bei Implementation entfernt werden public static void main(String[] args) { new ChatGUI();