New Line character different for two identical pieces of code?

Hey all, I have this code:

table.setDefaultEditor(Object.class,null);

Style style = currentDocument.addStyle("Table 1",null);

JTableHeader tableHeader = table.getTableHeader();

tableHeader.setReorderingAllowed(false);//so the user can't re-order the columns.

StyleConstants.setComponent(style, table.getTableHeader());//table header needs inserting first.

newLine();

currentDocument.insertString(currentDocument.getLength(),"This text is ignored by the compiler, but can't be blank.", style);

newLine();

StyleConstants.setComponent(style, table);

currentDocument.insertString(currentDocument.getLength(),"This text is ignored by the compiler, but can't be blank.", style);

Which works fine, it prints the header, immediately followed by the rest of the table. However, if I want to use this code elsewhere for another table, using:

final JTable table =new JTable(table2, tableX[0]);

table.setPreferredScrollableViewportSize(new Dimension(400,70));

table.setDefaultEditor(Object.class,null);

Style style = currentDocument.addStyle("Table 1",null);

JTableHeader tableHeader = table.getTableHeader();

tableHeader.setReorderingAllowed(false);//so the user can't re-order the columns.

StyleConstants.setComponent(style, table.getTableHeader());//table header needs inserting first.

newLine();

currentDocument.insertString(currentDocument.getLength(),"This text is ignored by the compiler, but can't be blank.", style);

newLine();

StyleConstants.setComponent(style, table);

currentDocument.insertString(currentDocument.getLength(),"This text is ignored by the compiler, but can't be blank.", style);

I end up with an extra line in between the header and the rest of the table. If I try changing the currentDocument.getLength() to currentDocument.getLength() -1 (in an attempt to get rid of a /n), I end up with the header and the first row on the same line.

It is worth noting that both sets of code are used (for testing) in the same class, and the second one is run first, with different results.

My new line method is:

privatevoid newLine(){

try{

currentDocument.insertString(currentDocument.getLength(),"\n",null);

}

catch (BadLocationException e){

//do nothing

}

}

Thank-you in advance for any help, this is driving me crazy.

[3414 byte] By [abu5ea] at [2007-11-26 21:21:43]
# 1
Never mind, I have fixed this one. Please look at my other threads, and thank-you for your time.
abu5ea at 2007-7-10 3:01:09 > top of Java-index,Desktop,Core GUI APIs...