Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop horizontal scrolling in JTextArea

I want to add a JTextArea to an application. Normally that textarea contains large content and both horizontal and vertical ScrollBars appear when running that application. I want to remove horizontal scrolling; I have found that it is possible with HORIZONTAL_SCROLLBAR_NEVER field but then it does not show the complete contents (it doesn't wrapped horizontally and move content to next row). how to overcome this. I want to stop horizontal scrolling and put contents in next row without scrolling it on a row.

like image 530
Mad Avatar asked Jul 29 '11 19:07

Mad


People also ask

How do I disable horizontal scrolling in Java?

Just set the display to "none" using the CSS class for the horizontal bar.

How do I stop JTextArea from expanding?

You can use JTextArea#setLineWrap(true) by default is set to false. Sets the line-wrapping policy of the text area. If set to true the lines will be wrapped if they are too long to fit within the allocated width. If set to false, the lines will always be unwrapped.


1 Answers

Try this:

yourJTextArea.setLineWrap(true);
yourJTextArea.setWrapStyleWord(true);
like image 166
Eng.Fouad Avatar answered Oct 12 '22 01:10

Eng.Fouad