?
Solved

Displaying lots of text

Posted on 2004-04-13
8
Medium Priority
?
190 Views
Last Modified: 2010-03-31
hi,

i'm new here but this is fairly urgent and any help would be much appreciated.

I'm trying to display the values of an array that can be have up to 50000 elements in it.  to do it, it iterate it in a loop and then add it to the component.  I've tried using textpanes, textareas etc. but they seem to be running VERY slowly and taking a long time to display the numbers.  I've even tried concatenating all the elements of the array into one string to display them, but thats just as slow.  does anyone have any solutions to make it appear as quickly as possible

cheers
0
Comment
Question by:Paul_Murphy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10817253
Please post code
0
 
LVL 92

Expert Comment

by:objects
ID: 10817572
Add all your elements to a DefaultListModel and display using a JList
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 10817734
If all you're doing is displaying the elements, you can probably use Strings. Something like:

final int AVERAGE_ELEMENT_LENGTH = 10;
final int BUF_SIZE = 50 * 1000 * AVERAGE_ELEMENT_LENGTH; // or whatever
StringBuffer sb = new StringBuffer(BUF_SIZE);
for(int i = 0;i < yourArray.length;i++) {
      if (yourArray[i] != null) {
            sb.append(yourArray[i].toString());
            /*
             * if it contains primitives (also change
             * the above check to 0 instead of null)
             *
             * sb.append("" + yourArray[i]);
             */
      }
}      
yourComponent.setText(sb.toString());



0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10820387
If it is from a file then

Read the file using buffered reader.

BufferedReader reader = new BufferedReader(new FileReader(new File(<file name with path>)));
StringBuffer buffer = new StringBuffer();

String line  = null;
while ((line = reader.readLine()) != null)
      buffer.append(line);


textArea.setText(buffer.toString());

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10822082
8-)

With that StringBuffer, you'll get best performance from it if you always initialize it with a size slightly greater than you're going to need
0
 

Author Comment

by:Paul_Murphy
ID: 10822161
yeah, i've done that.  Thanks a million for the help
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10822175
No problem :-)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 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