Mega Code Archive

 
Categories / Java Tutorial / Swing Event
 

Creating the GUI on the Event-Dispatching Thread

import javax.swing.JFrame; import javax.swing.SwingUtilities; public class EventDispatchThread {   public static void main(String[] args) {     SwingUtilities.invokeLater(new Runnable() {       public void run() {         creatGUI();       }     });   }   static void creatGUI() {     JFrame window = new JFrame("Sketcher"); // Create the app window     window.setBounds(30, 30, 300, 300); // Size     window.setVisible(true);   } }