Search code examples
javaswingjtextareaword-wrap

How to wrap text in a JTextArea


I have a JTextArea in Java. When I place a large amount of text in it, the text area provides horizontal scrolling.

How can I make my text area wrap instead?


Solution

  • Use the JTextArea#setLineWrap method. This is also illustrated in the Swing JTextArea tutorial