I have an application that is receiving text from the user then putting it into a jLabel. It does some processing on the text so I thought that it was a problem with that but after some troubleshooting I have isolated the most time consuming part of the program.
text1.setText( arg2 );
Where arg2 is a long string. In testing I have been using 9000 lines. It is also formatted in HTML. Where I would think it may take some time, a few seconds, it is taking a huge amount of time, 3 minutes and 35 seconds. I have found some questions here that have similar problems with jTextArea:
https://stackoverflow.com/questions/23951118/jtextarea-settextverylongstring-is-taking-too-much-time
But I cannot find a way to apply that solution to this problem. Is there a solution for this?
EDIT - My code is below. Note I have cut down the middle part of the string for brevity.
import java.io.*;
import java.lang.*;
import javax.swing.*;
public class jLabelIssue {
public static void main( String[] args ) {
final JFrame frame = new JFrame( "Comparinger use this to compare things and stuff" );
frame.setSize(268, 150);
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setVisible( true );
JLabel text1 = new JLabel( );
frame.add( text1 );
arg2 =
"<HTML><font color=black>" +
"a<br/>" +
"a<br/>" +
"a<br/>" +
//... 9000 more lines of this ...
"a<br/>" +
"a<br/>" +
"a<br/>" +
"</font></HTML>";
text1.setText( arg2 );
frame.repaint();
}
}