1

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.

Jay
  • 2,394
  • 11
  • 54
  • 98
  • 2
    Better post a good [SSCCE](http://sscce.org/), since the code you are referring to, is not complete in any way. Regards – nIcE cOw Jan 28 '12 at 13:35

2 Answers2

3

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

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • I think you mean unresponsive nor unresponsible ;) – npinti Jan 28 '12 at 09:43
  • I tried invoking the method that writes to the textpane from inside a runnable in SwingUtilities.invokeLater - it did not work :( – Jay Jan 28 '12 at 11:25
3

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.

npinti
  • 51,780
  • 5
  • 72
  • 96
  • doesn't work with SwingUtilities.invokeLater :( - the textpane never gets updated. – Jay Jan 28 '12 at 11:26