From e3c748b0fa637b58d0ea01cf1c588bc16ddc7575 Mon Sep 17 00:00:00 2001 From: Michael Best Date: Tue, 28 Mar 2023 17:31:02 -0600 Subject: [PATCH] Change how placeholder text is displayed and hidden (#64) * Change how placeholder text is displayed and hidden - based on the IntelliJ Platform UI Guidelines https://jetbrains.design/intellij/controls/input_field/#placeholder - remove focus event and listener * Remove color styling on input box text --- .../toolwindow/components/TextArea.java | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/main/java/ee/carlrobert/codegpt/toolwindow/components/TextArea.java b/src/main/java/ee/carlrobert/codegpt/toolwindow/components/TextArea.java index b144e90e..7f91551c 100644 --- a/src/main/java/ee/carlrobert/codegpt/toolwindow/components/TextArea.java +++ b/src/main/java/ee/carlrobert/codegpt/toolwindow/components/TextArea.java @@ -3,23 +3,19 @@ package ee.carlrobert.codegpt.toolwindow.components; import static ee.carlrobert.codegpt.util.SwingUtils.addShiftEnterInputMap; import static ee.carlrobert.codegpt.util.SwingUtils.createIconButton; -import com.intellij.ui.JBColor; import com.intellij.ui.components.JBTextArea; import com.intellij.util.ui.JBUI; import icons.Icons; import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import javax.swing.JButton; import javax.swing.JScrollPane; public class TextArea extends JBTextArea { public TextArea(Runnable onSubmit, JScrollPane textAreaScrollPane) { - super("Ask me anything..."); - setForeground(JBColor.GRAY); + super(); + getEmptyText().setText("Ask me anything..."); setMargin(JBUI.insets(5)); - addFocusListener(getFocusListener()); addSubmitButton(onSubmit, textAreaScrollPane); addShiftEnterInputMap(this, onSubmit); } @@ -36,22 +32,4 @@ public class TextArea extends JBTextArea { button.addActionListener(submitButtonListener); return button; } - - private FocusListener getFocusListener() { - return new FocusListener() { - public void focusGained(FocusEvent e) { - if (getText().equals("Ask me anything...")) { - setText(""); - setForeground(JBColor.BLACK); - } - } - - public void focusLost(FocusEvent e) { - if (getText().isEmpty()) { - setForeground(JBColor.GRAY); - setText("Ask me anything..."); - } - } - }; - } }