Browse Source

refactoring: EmojiPicker3

remotes/origin/client-handler
Valentin Spiroski 11 months ago
parent
commit
edd14a5824
  1. 13
      src/main/java/EmojiPicker.java

13
src/main/java/EmojiPicker.java

@ -20,19 +20,20 @@ public class EmojiPicker extends JPanel {
* @param textField The JTextField to append selected emojis. * @param textField The JTextField to append selected emojis.
*/ */
public EmojiPicker(JTextField textField) { 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) { for (String emoji : emojis) {
JButton emojiButton = new JButton(emoji); 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 class EmojiActionListener implements ActionListener {
private String emoji; private String emoji;

Loading…
Cancel
Save