diff --git a/src/main/java/EmojiPicker.java b/src/main/java/EmojiPicker.java index 73bb1db..ad93e6a 100644 --- a/src/main/java/EmojiPicker.java +++ b/src/main/java/EmojiPicker.java @@ -3,16 +3,19 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - public class EmojiPicker extends JPanel { - - private static final String[] emojis = {"😀", "😃", "😄", "😁", "😆", "😅", "😂", "🤣", "😊", "😇", "🙂", "🙃"}; + private JTextField textField; + private static final String[] emojis = {"😀", "😃", "😄", "😁", "😆", "😅", + "😂", "🤣", "😊", "😇", "🙂", "🙃"}; + + + public EmojiPicker(JTextField textField) { - setLayout(new GridLayout(4, 3, 5, 5)); + for (String emoji : emojis) { JButton emojiButton = new JButton(emoji); emojiButton.setFont(new Font("Segoe UI Emoji", Font.PLAIN, 20)); @@ -21,7 +24,6 @@ public class EmojiPicker extends JPanel { } setPreferredSize(new Dimension(300, 200)); - } private class EmojiActionListener implements ActionListener { @@ -34,11 +36,11 @@ public class EmojiPicker extends JPanel { @Override public void actionPerformed(ActionEvent e) { - System.out.println("Selected emoji: " + emoji); textField.setText(textField.getText() + emoji); + } } - }} +}