Re: About JTextPane, Why "Not equal" ?



On Mar 31, 6:13 pm, Tom Hawtin <use...@xxxxxxxxxxxxxxxxx> wrote:
Andrew Thompson wrote:
On Mar 31, 6:08 pm, "SadRed" <cardinal_r...@xxxxxxxxxxx> wrote:
On Mar 31, 4:50 pm, "Red Orchid" <windfollowcl...@xxxxxxxxx> wrote:
..
I expected that "true" is printed. But the code above prints "false".
...
It does print "true".

Not here. Using your code (or mine),
Java 1.6.0, on WinXP, I get 'false'.

I get 'true' on Ubuntu with Java 1.6.0 and 1.4.2_13.

I suspect it has something to do with the 'null'
character attribute set, but am not sure.

The code compares the raw text, so the attributes should come into it.

The difference between JEditorPane.setText and Document.insertString
(other than that one replaces, etc) is that setText goes through the
EditorKit (which then calls insertString). So you can setText an entire
HTML document, if the JEditorPane is so configured.

For plain text, the PlainEditorKit attempts to cope with different new
line standard. It may not pass through the text unchanged. Mixing new
line standards, makes it go false for me.

String s = "\r\n123\n45\r\n6890";
^^
Tom Hawtin

PlainEditorKit
It's DefaultEditorKit. I saw the source code of
its read() method. And I just saw it is playing
with various line-end markers, '\n', '\r' and
'\r\n'. But nothing was clear to me. ;-)

.



Relevant Pages

  • Re: About JTextPane, Why "Not equal" ?
    ... Java 1.6.0, on WinXP, I get 'false'. ... character attribute set, but am not sure. ... The difference between JEditorPane.setText and Document.insertString is that setText goes through the EditorKit. ... the PlainEditorKit attempts to cope with different new line standard. ...
    (comp.lang.java.programmer)
  • Re: These are identical, right? char const* and const char*
    ... > embedded systems and many of the systems it runs on don't have things like ... Java was originally an embedded systems programming language, ... > aware that the omission of many things from the standard is inconvenient ...
    (comp.lang.cpp)
  • Re: Differences between C++ and Java
    ... > are *implementation* defined and the standard also specifies the ... > "In Java, garbage collection of unreferenced objects is automatic. ... > C++, you manually manage memory. ... > provide third party libraries that work just as well, ...
    (comp.lang.java.programmer)
  • Re: These are identical, right? char const* and const char*
    ... > and end to be a language that can run on a vast array of platforms. ... But there are many features in the standard library which /are/ directed ... > that you don't want to learn gains you the full power of the platform. ... work directly with the system API in Java as well. ...
    (comp.lang.cpp)
  • Re: Comparing Lisp conditions to Java Exceptions
    ... to be explicit on this and there was no money to do that project. ... there were things in the ANSI CL standard that defied ... I guess in all your advocacy of and/or comparison to Java I just missed ... >> Lisp vendors react to money, not rhetoric in the design of their product. ...
    (comp.lang.lisp)