In a "serious" Java GUI app, you'll have models behind many of your GUI elements: A DocumentModel
backing a JEditorPane
, for example, or a ListModel
behind a JList
.
We're always told not to make GUI changes from outside the Swing worker thread and given SwingUtilities.invoke...()
for working around that. Fine, I can live with that! It's certainly necessary (and works well) when changing attributes of GUI components directly.
Ideally, most of my GUI-visible changes will be to models, not to JComponents, anyway. But because they're GUI-visible, do they "count" as GUI changes? I.e. do change events and listeners provide the necessary decoupling, or do model changes need to be wrapped in invoke...()
as well?
Probably old hat to Swing pros, but I wasn't able to find any reference that clearly states one way or another.