How to make JTextPane line break [duplicate]

2019-01-28 19:56发布

问题:

This question already has an answer here:

  • JTextPane does not go to a new line? 3 answers

In Java Swing, The JTextPane do have word wrap when text exceeded width, but it does NOT line break for if there was a very long non-space string

How can I making line break for long non-space string in JTextPane?

Any ideas would be much appreciated, thanks.

回答1:

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 answer from comment