943,695 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 935
  • Java RSS
Nov 27th, 2006
0

Preformatting

Expand Post »
Hi everyone,

I am currently trying to use the HTML preformat tags in a JTextPane using the the HTMLDocument class.

This is the function where i apply the preformating

Java Syntax (Toggle Plain Text)
  1. public void preformat(String str6)
  2. {
  3. SimpleAttributeSet sas1 = new SimpleAttributeSet();
  4. sas1.addAttribute(HTML.Tag.PRE, str6);
  5.  
  6. //apply the attribute to the selected text
  7. //This part is correct so i will not list it
  8. //as i am more concerned of the above two lines
  9. }

Now i am able to save the preformated text as HTML but the the problem starts when i read it back, there seems to be additional 2 carriage returns where there should only be one.
This occurs only when i read the HTML document using the html kit class but when i use a browser to read the html file there are no extra carriage returns.

The reading of the document is correct as this problem only occurs when the preformat tags are involved, else the problem does not exist at all.

This is how the reading of the document is done

Java Syntax (Toggle Plain Text)
  1. htmlkit.read(in, htmldoc, 0);
  2. ss = htmldoc.getStyleSheet();
  3. TextPane1.setDocument(htmldoc);

As you can see its unlikely anything is wrong with it but do correct me if i am wrong.

My question is why do these extra carriage returns occur?

Am i applying the preformat tags wrongly somehow?

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: project problem
Next Thread in Java Forum Timeline: Simpl JBank application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC