Actually, it JTextAreaalways has the correct size, so all lines of text are visible. You probably experience that you wrapped the text area in JScrollPane. Just lower the scroll area and make the text area a direct child of the container.
Another solution is to listen to events that change the size of the text area and, accordingly, the size of the scroll area. This way you can grow to a certain size and then start displaying scroll bars (for example, when someone inserts 500 KB of text into the text area).
source
share