aspose file tools*
The moose likes Beginning Java and the fly likes Spacings And Carriage Returns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Spacings And Carriage Returns" Watch "Spacings And Carriage Returns" New topic
Author

Spacings And Carriage Returns

Richard West
Ranch Hand

Joined: Jan 07, 2005
Posts: 127
Hi everyone,

I currently have a JTextPane using a html document and i am trying to serialize the html document contained in the JTextPane to the disk but i have run into some problems.

One problem lets say for example if i were to press the space bar five times and then type some text into the JTextPane and serialize it, everything seems alright except that when i read back the html document the space where i had pressed for five times has dissappeared and the text that i typed in is just left justified.

Another problem i have lets say for example if i were to press the carriage return five times and then type some text into the JTextPane and serialize it, everything seems alright except that when i read back the html document the carriage returns where i had pressed for five times has dissappeared and the text that i typed in is just placed at the top of the document in the JTextPane.

Why this is happening i am not sure but i am providing a compilable example for you guys to see what actually the problems that i am currently facing.

Here is the compilable example.



My only idea i guess is that i must be serializing the document wrongly, but i tried to yahoo but came up with nothing.

I hope someone knows why this is happening as already i am out of ideas.

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Interesting. It doesn't encode the blanks as nbsp, so when they are loaded back in they aren't rendered. It's standard HTML rendering to ignore leading white space and even empty paragraphs. They'd need something like nbsp to make them retain vertical space.

Is HTML a requirement? If you wrote this out as plain text it might load back into the TextPanel more the way you want it.

BTW: I left ampersand and semicolon off nbsp after some trouble saving this.
[ September 07, 2006: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[Stan]: BTW: I left ampersand and semicolon off nbsp after some trouble saving this.

To write " " in UBB, you need to escape the & by writing " ".

To write " " in UBB, you need to escape the & by writing " ".

To write " " in UBB, you need to escape the & by writing " ".

You get the idea.
[ September 07, 2006: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Thanks, Jim. See This Thread for more details.
 
 
subject: Spacings And Carriage Returns