Java Tutorial/Swing Event/Event Dispatching Thread

Материал из Java эксперт
Перейти к: навигация, поиск

Creating the GUI on the Event-Dispatching Thread

   <source lang="java">

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

}</source>