From d9feac282d944e5c507d9bd08ee9473b899a3a9b Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Fri, 9 Feb 2024 21:48:38 +0100 Subject: [PATCH] refactoring: Emojis in ChatClient --- src/main/java/ChatClient.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index 6a3e773..b4be3a3 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -77,10 +77,10 @@ public class ChatClient extends JFrame implements KeyListener { private Timer timer; private JLabel timeLabel; + // Emoji private JButton emojiButton; private EmojiPicker emojiPicker; - public ChatClient() { super("Chat"); address = JOptionPane.showInputDialog("bitte IP-Adresse"); @@ -121,11 +121,15 @@ public class ChatClient extends JFrame implements KeyListener { inputTextField = new JTextField(); inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben")); inputTextField.addKeyListener(this); - + + // Create a panel to hold input text field and emoji picker JPanel inputPanel = new JPanel(new BorderLayout()); - inputPanel.add(inputTextField, BorderLayout.CENTER); + inputPanel.add(inputTextField, BorderLayout.CENTER); // Add input text field to the center of the panel + + // Initialize EmojiPicker and add it to the input text field emojiPicker = new EmojiPicker(inputTextField); + // Create a panel to hold emoji button JPanel emojiPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); emojiButton = new JButton("😀"); emojiButton.setPreferredSize(new Dimension(50, 50));