0

I'm currently using a jTextArea, and that has a setLineWrap() method to indicate whether text should be wrapped or not. Do jTextPanes have an equivalent to this? I know it can wrap words, but I need it to wrap characters.

For example, "oooooooooooo..." should be wrapped and displayed as two or more lines of o's instead of one long line with a scroll bar. So is this possible with jTextPanes?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Saurav
  • 45
  • 4
  • Did you check [this question][https://stackoverflow.com/questions/7036543/how-is-word-wrapping-implemented-in-jtextpane-and-how-do-i-make-it-wrap-a-strin]? The link is off-site, but it appears to be related to the editorkit that's used for it. – Anya Shenanigans May 11 '21 at 20:12

1 Answers1

0

JTextPanes word wrap automatically, you have to set the size.

jTextPane.setSize(someValue);

The size should be set to something small.

But this doesn't help you because it doesn't do that with characters... Try using <br> maybe? Or check this link: http://java-sl.com/wrap.html

J Reyn
  • 21
  • 5
  • It seems the Website http://java-sl.com is offline (anyone knows what happened to that site?) I found a archived version at archive.org - http://web.archive.org/web/20220203131713/http://java-sl.com/wrap.html – MadMike Nov 08 '22 at 08:02