How to: JTextPane auto wrapping NOT on word boundary

I put a JTextPane into a JScrollPane. As I tried, the JTextPane will auto-wrap a long line if it exceed the width of the display area. And the auto wrapping is based on word boundary, such as a space character.

My content contains a lot of space. And I want to display it literally. So I need auto-wrapping, but I want it happen ONLY at the maximum width of display area, NOT on word boundary.


What I have tried:

  • Replace all the space with ”, so literally, my content is a single big word.

Source: java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.