开发者

stop horizontal scrolling in JTextArea

开发者 https://www.devze.com 2023-03-24 11:34 出处:网络
I want to add a JTextArea开发者_如何学JAVA to an application. Normally that textarea contains large content and both horizontal and vertical ScrollBars appear when running that application. I want to

I want to add a JTextArea开发者_如何学JAVA 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.


Try this:

yourJTextArea.setLineWrap(true);
yourJTextArea.setWrapStyleWord(true);


You can change the scroll bar policy:

JScrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);

This will disable the horizontal scroll bar

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号