Painting a region of DefaultStyledDocument content on to JTextPane

Hi
I have huge amount of text added to defaultStyledDocument, if I paint whole style document content on to JTextPane, it takes high CPU for painting huge text.
I would like to paint portion of  defaultStyledDocument's content (may be based on offset) based on scroll pane linked to JTextPane.
Please let me know how do I achieve this.
harishalwalaAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Use http://download.oracle.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html#getText(int, int)
e.g.
ta.setText(doc.getText(0, 255));

Open in new window

0
 
CEHJCommented:
Why paint - why not copy the content?
0
 
harishalwalaAuthor Commented:
I use styledDocument.insert() api to add the text content.
do you mean something else?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
CEHJCommented:
I'm interested in why you use the term 'paint' and am wondering if you're using it for a specific reason
0
 
harishalwalaAuthor Commented:
ok,
My intention is to say show part of the styleddocument content on to the TextPane.
Hope you are clear now.
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.