Placeholder in TextArea
See original GitHub issueHey,
I was wondering whether it was a conscious decision to not offer a placeholder for JTextArea
. I’ve seen you are using the default logic from Java via reflection to draw a clipped String
. I am assuming you didn’t implement this because it would require reimplementing the drawing and clipping a bit? Would you be accepting this as a PR if I was to try it with line wrapping AND clipping?
Alternatively a non wrapping version might already be better than nothing.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
HTML textarea placeholder Attribute - W3Schools
The placeholder attribute specifies a short hint that describes the expected value of a text area. The short hint is displayed in the...
Read more >HTML | <textarea> placeholder Attribute - GeeksforGeeks
The <textarea> placeholder attribute in HTML is used to specify the expected value to be displayed before user input in textarea element.
Read more >HTML placeholder Attribute - Tutorialspoint
HTML placeholder Attribute - The placeholder attribute of the <textarea> element is used to set a placeholder text in the textarea. A placeholder...
Read more >HTML5 textarea placeholder not appearing - Stack Overflow
I cannot figure out what is wrong with my markup, but the placeholder for the text area will not appear.
Read more >HTML textarea placeholder Attribute - Dofactory
The placeholder attribute adds a hint to a <textarea> element. The hint appears as muted text inside the control and specifies what data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
no, simply did not need it… 😉
yes, why reinvent/reimplement something that the JRE provides.
Sure.
There is already some code in FlatLaf that splits a string and paints multiple lines:
https://github.com/JFormDesigner/FlatLaf/blob/d10bcfc72fda6156ab104e1c52835eeef4282b2c/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolTipUI.java#L121-L132
Maybe extract this to new method
FlatUIUtils.drawMultiLineString( JComponent c, Graphics g, String text, int x, int y, int width, boolean clipLines )
and use it for TextArea placeholder too ?Reuse
JTextField.placeholderText
.Since the license of OpenJDK is GPL, it is not allowed to copy code from OpenJDK to FlatLaf (Apache license).
You could create a second
JTextArea
and use that for rendering the placeholder text…