From ba3b8fa4e045cd5e3187f67f5e9e7083a2713564 Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Fri, 9 Feb 2024 21:52:38 +0100 Subject: [PATCH] refactoring: Emojis in ChatClient3 --- src/main/java/ChatClient.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index 30a7136..e7df403 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -148,16 +148,15 @@ public class ChatClient extends JFrame implements KeyListener { } private void showEmojiPicker() { - JDialog emojiDialog = new JDialog(this, "Emoji Picker", true); - emojiDialog.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - emojiDialog.getContentPane().add(emojiPicker); - emojiDialog.pack(); - emojiDialog.setLocationRelativeTo(this); - emojiDialog.setVisible(true); - + // Create a dialog to display the emoji picker + JDialog emojiDialog = new JDialog(this, "Emoji Picker", true); // Create a modal dialog with a title "Emoji Picker" + emojiDialog.setDefaultCloseOperation(DISPOSE_ON_CLOSE); // Set close operation to dispose the dialog when closed + emojiDialog.getContentPane().add(emojiPicker); // Add the emoji picker component to the content pane of the dialog + emojiDialog.pack(); // Pack the dialog to fit the preferred size of its components + emojiDialog.setLocationRelativeTo(this);// Set the location of the dialog relative to the parent frame + emojiDialog.setVisible(true); // Make the dialog visible } - private void receiveMessages() { try { connectionToServer = new Socket(address, Constants.PORT);