views:

152

answers:

1

Hi All,

I'm currently working in Swing UI Assignment. This work involves showing large file content in JTextArea. The file size can be as large as 2 GB.

My initial idea is to lazily load content from the file, say 1 MB of content will be shown to the user. As the user scrolls i will retrieve the next 1 MB of content to be shown. All these operation will be happening in background thread (Swing Worker).

I looked at the JTextArea API, the method insert takes String and int(position of the insert) as the parameter.

This will suffice, but i'm worried about performance, because the content (1 MB at a time) retrieved will have to be converted to String object.

Is there any other work around or any other alternative/better solution for this.

+3  A: 

The efficiency issue would lie in the Document model.

The way to go is probably to provide an efficient custom Document implementation.

However, personally, I would try to reconsider and try to have a different user interface. Who would want to scroll through 2 GB of data anyway?

aioobe