It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes How to stop text continuing horizontally in a textarea? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "How to stop text continuing horizontally in a textarea?" Watch "How to stop text continuing horizontally in a textarea?" New topic
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
    
    2
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to stop text continuing horizontally in a textarea?
 
Similar Threads
JScrollPane is scrolled down - how to set it up and let the user scroll is down?
JTextArea update, URGENT HELP PLS
Help,Components inside my Frame would not be displayed until maximized.
Large Tekst input field with scrool bar
Locking the JText Area