> Sorry, of cource ! Thi is the way I do it:
> But its still not working. The text gets chunked and displayed in worng
> order. Or the text get truncated.
(a) Fix the obvious bug in your code:
> while ((r = brFile.read(chBuff, 0, chBuff.length - 1)) != -1)
> {
[quoted text clipped - 7 lines]
> }
> });
If the next iteration of the while loop happens before the event loop
has processed the runnable, then str is replaced with the next buffer,
and the str contents is lost and never added to the text area. Instead
the second str contents will be added twice. If the while loop is much
faster than the event processing, then you get even more of this behavior.
If fixing this bug doesn't fix all your problems, continue with (b).
(a1) Not relevant here, but re-read the API documentation of read() and
a Java textbook, which explains arrays and the java char type:
> while ((r = brFile.read(chBuff, 0, chBuff.length - 1)) != -1)
The "- 1" in "chBuff.length - 1" is unnecessary. Java is not C or C++.
(b) Build a reliable test case: Figure out at which text size the
problems exactly start (up to a one byte precision). Investigate that
number. Does it look familiar? Is it some typical multiple of 2? How
does it look in binary? Does it ring a bell?
(b1) Consider http://www.physci.org/codes/sscce.jsp You might also
consider finally telling us what is a "large file" for you. Are we
talking gigabytes here?
(c) Figure out which of the involved objects has the problem, e.g. by
using a debugger and observing the object's state and looking for wild
changes / overflows when approaching the the magic file size you just
figured out in (b).
(d) Replace that particular object with an own implementation. Potential
candidates are:
- The default Document used by the JTextArea
- The JTextArea widget
- The ScrollPane
- The slider at the scroll pane
/Thomas
Robert Ludewig - 18 Apr 2004 09:45 GMT
hm converting swingutilitiest.invokelater to invokeandwait seem to
completely solve that problem
Just courious, what did u waht to hint to in (b)?