About JTextPane, Why "Not equal" ?




See this code.

<code>
// JDK 1.5.0_11
void process() throws BadLocationException {

String s = "\r\n12345\r\n6890";

JTextPane p0 = new JTextPane();
JTextPane p1 = new JTextPane();

///////////////////////////////////
// Irrelevant to this issue
// p0.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\r\n");
// p1.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\r\n");
///////////////////////////////////

p0.setText(s);
p1.getDocument().insertString(0, s, null);

String r0 = p0.getText();
String r1 = p1.getText();

System.out.println(r0.equals(r1));
}
</code>

I expected that "true" is printed. But the code above prints "false".
Why ? Is it proper behavior of JTextPane ?

Thanks.

.



Relevant Pages

  • Editor Kit mystery? I dont get it.
    ... I build a JTextPane which is editable, save it to a file, and load it ... back after which it's editing behavior is completely whacked out. ... Then I save the contents as a string put into a larger XML file like ... writer = new CharArrayWriter; ...
    (comp.lang.java.programmer)
  • Re: A Simple jTextPane Problem
    ... How do I code a jTextPane so that when a user clicks on (let say the ... JTextPane textPane1 = new JTextPane; ... public static void main(final String[] args) ... ClickedPaneListener(JTextPane fromPane, JTextPane toPane) { ...
    (comp.lang.java.beans)
  • Linefeed und Carriage Return in JTextPane - gewollt bzw. wie verhindern?
    ... verarbeiten. ... Der String, den ich mit getText() bekomme enthält CR+LF. ... Warum taucht also im Text des JTextPane 'A'LFCR'B' auf? ...
    (de.comp.lang.java)
  • Re: About JTextPane, Why "Not equal" ?
    ... void process() throws BadLocationException { ... JTextPane p0 = new JTextPane; ... String r0 = p0.getText; ... public class RedOrchid{ ...
    (comp.lang.java.programmer)
  • Re: JTextPane: find the length of invisible text ?
    ... I'm searching a way to find the length of the text in a JTextPane ... Or you could directly try rendering the string onto an offscreen buffer ... Oliver ...
    (comp.lang.java.gui)