Creating the GUI on the Event-Dispatching Thread : Event Dispatching Thread « Swing Event « Java Tutorial






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);
  }
}








15.14.Event Dispatching Thread
15.14.1.Creating the GUI on the Event-Dispatching Thread