SwingUtilities.invokeLater in AWT Event Dispatching Thread

If you use SwingUtilities.invokeLater(Runnable) , if you change the GUI and you are in the Dispatcher theme of an AWT event, such as ActionListener ?

+6
source share
1 answer

You should always update the GUI in the event dispatch stream (EDT). However, as Jeffrey notes in the comments, the ActionListener.actionPerformed method of the ActionListener.actionPerformed object is already called from the EDT.

If you just want JButton look at / unenabled enabled or add / remove elements from the JList and you make these changes through the ActionListener in the Swing component, then you do not need to invoke SwingUtilities.invokeLater explicitly.

+5
source

Source: https://habr.com/ru/post/915739/


All Articles