import javax.swing.JFrame; import javax.swing.JLabel; public class HelloWithDelayedRun { public static void runHelloFrame() { JFrame frame = new JFrame("Frame window with a label"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Hello World"); frame.add(label); frame.setSize(200, 100); frame.setVisible(true); } public static void main(String[] args) { // Tell the even-dispatching thread to schedule // a job that runs our runHelloFrame method. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { runHelloFrame(); } }); } }