[Solved] Newline character \n treated as paragraph break

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
vstypicals
Posts: 2
Joined: Thu Sep 18, 2008 1:59 am

[Solved] Newline character \n treated as paragraph break

Post by vstypicals »

Hello,

I'm trying to insert a JTextPane into OOo Writer from Java, and everyone seems to be going well except that "\n" in Java are treated as hard carriage returns or paragraph breaks when the JTextPane is inserted into a OOo Writer document. This leaves an extra space between the lines which I don't want. I need a "soft" carriage return, e.g., pressing shift + enter instead of just enter.

Here is a snippet of my code where txtDetails is a JTextPane:
xParagraphCursor.setString( txtDetails.getText().toString() );

If anybody has any information on this, I would greatly appreciate it.

Thanks,
Jeff
Last edited by Hagar Delest on Thu Sep 18, 2008 10:06 pm, edited 1 time in total.
Reason: tagged the thread as Solved.
OOo 2.4.X on Ms Windows XP
vstypicals
Posts: 2
Joined: Thu Sep 18, 2008 1:59 am

Re: Newline character \n treated as paragraph break

Post by vstypicals »

Switching from JTextPane to JTextArea solved the problem. I'm guessing that it was because of the way JTextPane formats text. On some instances, the text would display fine (without extra space between lines), and on some cases, it would have the extra space between the lines. I didn't really dig too deep into it.

In any case, switching to JTextArea solved the issue.
OOo 2.4.X on Ms Windows XP
Post Reply