?
Solved

Painting a region of DefaultStyledDocument content on to JTextPane

Posted on 2011-10-27
6
Medium Priority
?
413 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:harishalwala
  • 4
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 37038606
Why paint - why not copy the content?
0
 

Author Comment

by:harishalwala
ID: 37038633
I use styledDocument.insert() api to add the text content.
do you mean something else?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37038712
I'm interested in why you use the term 'paint' and am wondering if you're using it for a specific reason
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:harishalwala
ID: 37043650
ok,
My intention is to say show part of the styleddocument content on to the TextPane.
Hope you are clear now.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 37043799
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 37049592
:)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question