My JPanel contains a JEditorPane. I use the JEditorPane as output.
The text of JEditorPane is changed very frequently and sometimes the text is large (more than 5000 lines).
To show text I am using SwingUtilities.invokeLater(Runnable run)
If the contentType of JEditorPane is "text/plain" the text loads faster than "text/html".
Can I insert first the text into the JEditorPane as plain text and then change the contentType?
Joined: Oct 13, 2005
You have got the wrong sort of thing in the run() method. You only need to create the GUI in that method; then don’t start any new threads which affect Swing objects.This assumes that all code required to display the GUI can be accessed (albeit indirectly) from the MyGui() constructor.
I had to edit this post twice because I noticed mistakes in it.
The event dispatch thread, where all event-handling code is executed. Most code that interacts with the Swing framework must also execute on this thread.
Worker threads, also known as background threads, where time-consuming background tasks are executed.
I am novice and I want you to correct my thinking. So all GUIs update must be done from EDT. That's why I use SwingUtilities.
I dont use SwingWorker because SwingWorker must be used for background long-running tasks.
Here is a SSCCE example. I read a large text file and I show it in a JEditorPane.
How can I increase the speed of insertion in a JEditorPane?