Re: About JTextPane, Why "Not equal" ?
- From: "SadRed" <cardinal_ring@xxxxxxxxxxx>
- Date: 31 Mar 2007 01:08:08 -0700
On Mar 31, 4:50 pm, "Red Orchid" <windfollowcl...@xxxxxxxxx> wrote:
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.
It does print "true".
-------------------------------------------------
import javax.swing.*;
public class RedOrchid{
public static void main(String[] args) throws Exception{
String s = "\r\n12345\r\n6890";
JTextPane p0 = new JTextPane();
JTextPane p1 = new JTextPane();
p0.setText(s);
p1.getDocument().insertString(0, s, null);
String r0 = p0.getText();
String r1 = p1.getText();
System.out.println(r0 + " " + r1 + "\n" + r0.equals(r1));
}
}
-------------------------------------------------
.
- Follow-Ups:
- Re: About JTextPane, Why "Not equal" ?
- From: Andrew Thompson
- Re: About JTextPane, Why "Not equal" ?
- References:
- About JTextPane, Why "Not equal" ?
- From: Red Orchid
- About JTextPane, Why "Not equal" ?
- Prev by Date: About JTextPane, Why "Not equal" ?
- Next by Date: Jframe
- Previous by thread: About JTextPane, Why "Not equal" ?
- Next by thread: Re: About JTextPane, Why "Not equal" ?
- Index(es):
Relevant Pages
|