Like any other java program, every swing program starts with a main method. The main method is initiated by the main thread. However, Swing components need to be created and updated on the event dispatch thread (or short: EDT). To illustrate the dynamic between the main thread and the EDT take a look at this Hello World! example.
The main thread is just used to delegate the creation of the window to the EDT. If the EDT is not initiated yet, the first call to SwingUtilities.invokeLater
will setup the necessary infrastructure for processing Swing components. Furthermore, the EDT remains active in the background. The main thread is going to die directly after initiating the EDT setup, but the EDT will remain active until the user exits the program. This can be achieved by hitting the close box on the visible JFrame
instance. This will shutdown the EDT and the program's process is going to entirely.