JFrame in event despatch thread
I normally create a jframe with all the standard methods but I was reading about GUI on the oracle website and it showed an example of creating a jframe in a new instantce of runnable on something called an event despatch thread hear is the link Creating the Demo Application (Step 1) (The Java™ Tutorials > Creating a GUI With JFC/Swing > Performing Custom Painting) can you tell me the benefits of using this and what it does exactly, thanks.
Re: JFrame in event despatch thread
Everything Swing related is done on the EDT, or Event Dispatching Thread. Painting, event handling, gui updating, etc. This keeps things organized, as making changes to the GUI from multiple Threads can result in pandemonium.
So, if you're doing something on another Thread and you want to make a change to the gui, you should do it on the EDT. You do that by calling invokeLater() or invokeAndWait().
And since technically the main Thread (the Thread that invokes the main method) is a separate Thread, it's a good practice to use invokeLater() or invokeAndWait() to make gui changes, including creating and showing a JFrame.