Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JTextPane support text memory paging?

I'm trying to improve an existing implementation of document displaying component. One of the concerns expressed, that when loading a large bulk of text we will get an OOM exception.

From my previous experience with .net I do know that some base component implement paging, hence no all the text is visual loaded into the document hence things not only work faster but we will also, hopefully, avoid an OOM exception.

So I was wondering are there any base swing components, specifically JTextPanel, which support these capabilities?

Thank you for your help it is greatly appreciated

like image 767
jonatzin Avatar asked Jul 01 '26 07:07

jonatzin


1 Answers

It seems that Swing decouples the actual storage of the document from its presentation.

I think you should be able to have the functionality you want by defining an AbstractDocument.Content implementation which takes care of the memory management (e.g. paging).

The DefaultStyledDocument takes an AbstractDocument.Content in its constructor, and the JTextPane takes a StyledDocument, so if you define that implementation you should be able to plug it in.

I haven't tried this, so it's just a suggestion - you might be able to find implementations online.

like image 163
Vlad Avatar answered Jul 03 '26 19:07

Vlad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!