• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JTextPane ignores new line HTML <br> tag when using custom HTMLEditorKit  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

In my application I use a JTextPane embedded in a JScrollPane to display text which is formatted using HTML tags. At first I used JTextArea but then switched to JTextPane to be able to use HTML and colors. Then I needed the JTextPane to support letter based wrapping instead of just the default wrapping by white space. In other words if the content is too long it should be wrapped and the horizontal scroll bar of the JScrollPane should not be visible.

Therefore, I found a solution in this answer that works perfectly:  Letter wrap in html in JEditorPane. It uses a custom HTMLEditorKit for the JTextPane.

But with this solution the JTextPane ignores any line breaks with the HTML tag <br>. I have to admit I don't really know how the code in the solution works. It would be great if someone could find out how to get the HTML new line <br> tag working with this solution.

TL;DR: how to get this custom HTMLEditorKit to support the HTML "<br>" tag?

Here is a minimal, complete & verifiable example:



 
Marshal
Posts: 60065
188
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm is right; please tell the people on dreamincode too that you have posted on several websites.
 
John Sams
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for posting on multiples sites, I didn't thought I get the solution this quick!

In fact, a german forum posting solved my problem. Here's the code:



thnaks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!