| | |
Preformatting
![]() |
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 7
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
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
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
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)
public void preformat(String str6) { SimpleAttributeSet sas1 = new SimpleAttributeSet(); sas1.addAttribute(HTML.Tag.PRE, str6); //apply the attribute to the selected text //This part is correct so i will not list it //as i am more concerned of the above two lines }
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)
htmlkit.read(in, htmldoc, 0); ss = htmldoc.getStyleSheet(); 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
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
![]() |
Other Threads in the Java Forum
- Previous Thread: project problem
- Next Thread: args.length
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component database developmenthelp eclipse error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online pearl problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor





