Hi Guys,
I am writing an app. in which I would like the user to be able to save and
load information typed into a jEditorPane. However, there seems to be
formatting that is crucial to me that is lost in this converstion. In
particular, when you "getText()" from a jEditorPane, tabs are encoded as
"\t" rather than "<tab>" and line breaks that have been entered into a table
are saved as "\n" rather than "<br>". Thus, when reloading the page, the
formatting is lost, as HTML treats the above characters as whitespace.
Search and replacing "\t" with <tab> may fix the first problem (before the
file is saved), but replacing "\n" with "<br>" would place breaks all over
the place.
Any suggestions would be greatly appreciated.
Cheers,
Scott.
Christian Kaufhold - 08 Sep 2003 23:31 GMT
Hello!
> I am writing an app. in which I would like the user to be able to save and
> load information typed into a jEditorPane. However, there seems to be
[quoted text clipped - 6 lines]
> file is saved), but replacing "\n" with "<br>" would place breaks all over
> the place.
1. There is no such thing as <tab> in HTML. It is confusing that HTML-
EditorKit maps the Tab key to inserting a Tab (instead of just inserting a
space or doing nothing and leave Tab for focus management).
2. Why should "line-breaks" be saved as <br> and not separate pararaphs?
3. The problem seems to be that within implied paragraphs (direct content
in <li> or <td> as in <table><tr><td>Content</td></tr></table) only work
if there is a single one of them. Otherwise all except the first must be
converted into real <p>-paragraphs (and then usually the first as well
for consistency). But this is not done by HTMLDocument.
See, for a start,
From: usenet@chka.de (Christian Kaufhold)
Subject: Re: HTML editor with JEditorPane - linebreaks
Newsgroups: comp.lang.java.gui
References: <7f2e4a3e.0203280043.58287b43@posting.google.com>
Message-ID: <1t3ca393f9i4017n64@simia.chka.de>
Date: Thu, 28 Mar 2002 22:17:57 -0000
Christian