Search code examples
javaswingline-breaksjtextpane

How to make JTextPane line break


In Java Swing, the JTextPane has word wrap when the text exceeds width, but it does NOT line break for when there's a very long non-space string.

How can I make a JTextPane line break for a long non-space string?

Any ideas would be much appreciated, thanks.


Solution

  • To allow letter wrap LabelView should be modified to override min width

    java-sl.com/tip_letter_wrap_java7.html you have to define min width for label view = 0

    Also this java-sl.com/tip_java7_text_wrapping_bug_fix.html could help

    Posted as an answer from my comment.