Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   JTextPane: omitting new line (\n) character (http://www.programmingforums.org/showthread.php?t=12474)

Riddick Jan 30th, 2007 12:08 PM

JTextPane: omitting new line (\n) character
 
Hi i have some code that searches elements of a jtextpane from one element to another looking for key words. However when i get a new keyword from a new line, a new line character proceeds it.

At least i assume that's what happened because I concatenated my keywork with a proceeding 'before' and preceeding 'after' and it came out like this

before
forafter

instead of beforeforafter

is there any way to check and remove the new line character from the keyword or any way to prevent it happening.

Thanks.

titaniumdecoy Jan 30th, 2007 4:13 PM

:

str = str.replaceAll("\\s", "");

Riddick Jan 30th, 2007 4:42 PM

Thanks for the answer i'll give it a try. Do you know if it will affect the way the document is saved and read back to the jtextpane?

hoffmandirt Feb 22nd, 2007 4:32 PM

If you perform the replace on the text inside the JTextPane, it will affect the way it is saved. An idea might be to keep an original copy of the text and create another copy to perform your string operations on.


All times are GMT -5. The time now is 1:45 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC