|
|
@ -20,19 +20,20 @@ public class EmojiPicker extends JPanel { |
|
|
|
* @param textField The JTextField to append selected emojis. |
|
|
|
*/ |
|
|
|
public EmojiPicker(JTextField textField) { |
|
|
|
setLayout(new GridLayout(4, 3, 5, 5)); |
|
|
|
|
|
|
|
setLayout(new GridLayout(4, 3, 5, 5)); // Set grid layout for the emoji buttons |
|
|
|
|
|
|
|
// Create and add buttons for each emoji |
|
|
|
for (String emoji : emojis) { |
|
|
|
JButton emojiButton = new JButton(emoji); |
|
|
|
emojiButton.setFont(new Font("Segoe UI Emoji", Font.PLAIN, 20)); |
|
|
|
emojiButton.addActionListener(new EmojiActionListener(emoji)); |
|
|
|
add(emojiButton); |
|
|
|
emojiButton.setFont(new Font("Segoe UI Emoji", Font.PLAIN, 20)); // Set font for emoji buttons |
|
|
|
emojiButton.addActionListener(new EmojiActionListener(emoji)); // Add action listener to each button |
|
|
|
add(emojiButton); // Add emoji button to the panel |
|
|
|
} |
|
|
|
|
|
|
|
setPreferredSize(new Dimension(300, 200)); |
|
|
|
setPreferredSize(new Dimension(300, 200)); // Set preferred size for the EmojiPicker panel |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class EmojiActionListener implements ActionListener { |
|
|
|
|
|
|
|
private String emoji; |
|
|
|