A “Submit Button” is presented WITHIN the text field, aligned at the right side.
Hint text is displayed when no text is entered by the user.
The user can input new-lines (e.g. copy-paste multiple lines of code, or press “SHIFT+ENTER” to add a new-line).
If JBTextField is not the right component to use, please advise on which one to use instead.
I tried using a JEditorPane, and it seems like I’m getting closer at least for the “multiple lines” things, but then I end up with some other issues I need to fix: the styling is wrong.
Is there a way to easily make it look like a JBTextField ? E.g. padding/insets, blue highlight when focused, normal font, etc.
Have you looked at ExtendableTextField ? You can probably register a custom ExtendableTextComponent.Extension that has submit like icon.
Or maybe ExpandableTextField, that looks like a regular text field, but when you edit it opens popup with a text area. This one has some interesting code that you maybe interested to as well.
You can tag your question with swing , so it’s easier to discover them
Turns out the easiest option for me was to use a JPanel with a custom border that was setup using JBUI.Borders stuff.
Then, this wrapper contained the JEditorPane I previously had, and I used addKeyboardAction to customize its behavior as I wanted.
This at least takes care of most of the UX requirements I had. The “internal button” requirement will probably be met by eventually refactoring this to use ExtendableTextField, as suggested above.