Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spacings And Carriage Returns

 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Jim. See This Thread for more details.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic