//package ex1; import javax.swing.*; // this is a very un-cluttered example public class BeSunny { private static void createAndShowGUI() { // ... set the 'look-and-feel' JFrame.setDefaultLookAndFeelDecorated(true); // ... create and set up the 'window frame' JFrame frame = new JFrame("sunshine"); // becomes title of 'frame' frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // shuts down program !! // ... create and add a 'label' JLabel label = new JLabel(" Is it still raining? "); frame.getContentPane().add(label); // ... build and display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { // ... M A I N !!!!!!!!!!!!!! // ... schedule a job for the 'event-dispatching thread' // ... creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater ( new Runnable() { public void run() { createAndShowGUI(); } // ... we defined this static method above } ); // ... defining an anonymous 'runnable' builds a thread to 'run' } // end of Main }