User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 402,008 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,427 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 663 | Replies: 0
Reply
Join Date: Jun 2004
Posts: 604
Reputation: freesoft_2000 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 6
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Help Preformatting

  #1  
Nov 27th, 2006
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

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

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
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 9:37 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC