Jay
Jay

Reputation: 2454

JTextPane content never updates - what am I doing wrong?

I've my pasted my source code here. The idea is to collect error messages and warnings in an application where each message is a paragraph with each paragraph describing parts of text with attributes. No matter, what I do the textpane would not display any text - I guess I have got something basic going wrong here. I can use some thoughts - thanks in advance, guys.

Upvotes: 1

Views: 154

Answers (2)

mKorbel
mKorbel

Reputation: 109815

1) you have got issue with Concurency, Swing is single threaded all changes from background task should be invoked EDT,

2) better would be initialize those code from Swingworker or Runnble#Thread,

3) if you don't want to solve that your GUI will be unresponsive or freeze durring this task, then wrap output to the Document inside invokeLater

Upvotes: 3

npinti
npinti

Reputation: 52185

All GUI changes need to be made through the use of the SwingUtilities.invokeLater method. This will place what you need on the EDT which then executes and displays your text on the screen.

Upvotes: 3

Related Questions