0

I've assimilated this idea that it is always bad to use a Swing component outside the EDT.
In my non-GUI program (as it currently is) I do however want to use some kind of marked-up string (containing non-visual logical styles that give some kind of "meta" info about bits of the string). DefaultStyledDocument works perfectly. But its package is of course javax.swing.text.

Am I alone in feeling it is inappropriate to use it in a non-EDT thread? Is there any alternative (other than to roll my own class or use the EDT despite having no GUI)?

Zoyd
  • 3,449
  • 1
  • 18
  • 27
mike rodent
  • 14,126
  • 11
  • 103
  • 157
  • 2
    You can safely use the Swing models outside the EDT, as long as they are not yet connected to a view. A more common example is to do a DB query and construct a `TableModel` on a background thread, and set the model to a `JTable` on the EDT. – Robin Oct 19 '13 at 10:11
  • Note that I didn't say they are thread-safe. But single-threaded access outside the EDT is allowed as long as they are not connected to a view – Robin Oct 19 '13 at 12:58
  • @Robin - understood ... by the way, I submitted a new answer to your qu from 2012 about a JTree with filter... http://stackoverflow.com/questions/9234297/filtering-on-a-jtree/19618192#19618192... I'd like your opinion of it if you have time – mike rodent Oct 27 '13 at 19:15

0 Answers0