简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM