| Author |
How to stop text continuing horizontally in a textarea?
|
Alan Smith
Ranch Hand
Joined: Oct 19, 2011
Posts: 150
|
|
Hi guys,
I have an editable textarea for writing text into complete with a scrollpane. The scrollpane constructor is 'sp = new JScrollPane(ta,sp.VERTICAL_SCROLLBAR_AS_NEEDED,sp.HORIZONTAL_SCROLLBAR_NEVER);' where ta is the textarea. The problem is that the text doesn't jump to the next line below when I reach the edge of the text area. Any help? I thought disabling the horizontal scrollpane would do it but it just disappears into the void!
Cheers
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
JTextArea#setLineWrap(true)
JTextArea#setWrapStyleWord(true)
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1790
|
|
Wrapping of text is controlled by the JTextAea. There are two methods of interest. One to turn "wrapping" on. The otther to control whether wrapping is done at the word or character level.
Also, there is no need to play with the scrollpane scrolling properties. Just create the scrollPane with the JTextArea as the only parameter.
|
 |
Alan Smith
Ranch Hand
Joined: Oct 19, 2011
Posts: 150
|
|
|
Thank you!
|
 |
 |
|
|
subject: How to stop text continuing horizontally in a textarea?
|
|
|