Browse Source

refactoring: Kommentare und Übersicht

remotes/origin/server
Paul Kattenborn 11 months ago
parent
commit
4ed49f7d4b
  1. 19
      src/main/java/ChatGUI.java

19
src/main/java/ChatGUI.java

@ -16,14 +16,19 @@ import javax.swing.JTextField;
public class ChatGUI implements ActionListener { public class ChatGUI implements ActionListener {
// Menu items for font sizes
JMenuItem small = new JMenuItem("small-font"); JMenuItem small = new JMenuItem("small-font");
JMenuItem medium = new JMenuItem("medium-font"); JMenuItem medium = new JMenuItem("medium-font");
JMenuItem large = new JMenuItem("large-font"); JMenuItem large = new JMenuItem("large-font");
JMenuItem exit = new JMenuItem("Exit");
// Menu items for font colors
JMenuItem black = new JMenuItem("black"); JMenuItem black = new JMenuItem("black");
JMenuItem red = new JMenuItem("red"); JMenuItem red = new JMenuItem("red");
JMenuItem blue = new JMenuItem("blue"); JMenuItem blue = new JMenuItem("blue");
JMenuItem green = new JMenuItem("green"); JMenuItem green = new JMenuItem("green");
JMenuItem exit = new JMenuItem("Exit");
JTextField inputTextField = new JTextField(); JTextField inputTextField = new JTextField();
JTextArea outputTextArea = new JTextArea(); JTextArea outputTextArea = new JTextArea();
@ -35,12 +40,13 @@ public class ChatGUI implements ActionListener {
// Set up the main frame // Set up the main frame
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setTitle("java-chat"); gui.setTitle("java-chat");
gui.setLayout(new BorderLayout()); gui.setLayout(new BorderLayout());
// Set up the menu bar
JMenuBar bar = new JMenuBar(); JMenuBar bar = new JMenuBar();
gui.setJMenuBar(bar); gui.setJMenuBar(bar);
// Create menu items and menus
JMenu options = new JMenu("options"); JMenu options = new JMenu("options");
JMenu colors = new JMenu("font-colors"); JMenu colors = new JMenu("font-colors");
JMenu size = new JMenu("font-size"); JMenu size = new JMenu("font-size");
@ -60,7 +66,8 @@ public class ChatGUI implements ActionListener {
size.add(small); size.add(small);
size.add(medium); size.add(medium);
size.add(large); size.add(large);
// Register action listeners for menu items
red.addActionListener(this); red.addActionListener(this);
blue.addActionListener(this); blue.addActionListener(this);
black.addActionListener(this); black.addActionListener(this);
@ -90,7 +97,7 @@ public class ChatGUI implements ActionListener {
gui.setSize(quarterWidth, quarterHeight); gui.setSize(quarterWidth, quarterHeight);
gui.setVisible(true); gui.setVisible(true);
} }
// main methode zum Testen, müsste bei Implementation entfernt werden
public static void main(String[] args) { public static void main(String[] args) {
new ChatGUI(); new ChatGUI();

Loading…
Cancel
Save