import javax.swing.*; publicclassHelloWorldSwing { /** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread. */ privatestaticvoidcreateAndShowGUI() { //Create and set up the window. JFrameframe=newJFrame("HelloWorldSwing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add the ubiquitous "Hello World" label. JLabellabel=newJLabel("Hello World"); frame.getContentPane().add(label); //Display the window. frame.pack(); frame.setVisible(true); } publicstaticvoidmain(String[] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(newRunnable() { publicvoidrun() { createAndShowGUI(); } }); } }