Should you use SwingUtilities.invokeLater(Runnable)
if you're modifying the GUI and you're in the AWT Event Dispatching Thread, such as an ActionListener
?
You must always do GUI updates in the Event Dispatch Thread (EDT). However, as Jeffrey points out in the comments, the ActionListener.actionPerformed
method on a Swing object is already invoked from the EDT.
If you simply want the JButton
to look enabled/unenabled or to add/remove items from a JList
, and your making those changes via an ActionListener
on a Swing component, then you shouldn't have to invoke SwingUtilities.invokeLater
explicitly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With