I’ve been messing around with various text components and I now come here for answers.
What I need is a area in which user can enter text using keyboard and/or copy/paste.
These are the requirements of the component:
Word wrap, ability to limit number of rows (word wraped ones), ability to prevent user from entering certain characters (or hitting enter for a newline), ability to expand and reduce height according to its content (to make content fit into the component and to have no (couple of pixels are fine) exces height left, ability to detect change of its height, either directly or by tracking the line number.
Have a look at the different Text Components provided by the Java API here: Using Text Components
in the above it has 3 different types of text components:
And it looks like the definition of the last
Styled Text Areasfits your needs:These would include the likes of:
JEditorPane)