my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Displaying a Huge Vector Quickly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Displaying a Huge Vector Quickly" Watch "Displaying a Huge Vector Quickly" New topic
Author

Displaying a Huge Vector Quickly

Arann King
Greenhorn

Joined: Jul 04, 2003
Posts: 2
Hi,
I am trying to optimize the display time for a large (8000+ element) Vector.
Each element of the Vector contains an Array of Strings returned from a search on a XML document.
I am currently displaying the contents in a (JTextArea text), by iterating through the Vector start to finish and calling text.append("").
This process takes significantly longer than a SAX parser iterating through a 1 million line XML file.
Would it be quicker if I used a Hashtable and if so can they be dumped into any swing component? Is there any other way to quickly display a Vector in swing.
Thanks in Advance.
Aran
Abhik Sarkar
Ranch Hand

Joined: Jun 14, 2003
Posts: 61
Hi,
How about appending everything to a StringBuffer and then calling setText on the JTextArea just once?
HTH,
Abhik.
Arann King
Greenhorn

Joined: Jul 04, 2003
Posts: 2
Hi thanks for the reponse,
I tryed using a StringBuffer and it is significantly faster however on repeated attempt I get a java.lang.OutOfMemoryError
I tried setting the Buffer to null after each search but to no avail.
Here is the extract
StringBuffer x = new StringBuffer();
for ( j = 0; j < tokens.length; j++) {
//casting object into a string array
a = (String[]) tokens[j];
//int t = j-1;
x.append("\n Result Number "+(j+1)+"\n");
for (int i = 0; i < a.length; i++) {
print = (String) a[i] + '\n';
x.append(print);
//print =print +'\n'+ aa;
}
x.append("\n");
//print =print +'\n';
}
//text.(print);
x.append("\n Number of Results = "+j);
text.setText(x.toString());
time();
x = null;
Any help appreciated.
Thanks
Aran
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Displaying a Huge Vector Quickly
 
Similar Threads
Assign an Array to an Array Element
Display a list in a JTable
Image display in layout manager
Synchronized data structure question
concurrent modification error