// // from http://en.wikipedia.org/wiki/Swing_(Java) on Feb 3 2012 // import java.awt.*; import javax.swing.*; public class SwingExample implements Runnable { public void run() { // Create the window JFrame f = new JFrame ("Hello, World!"); // Set the behaviour for when the window is closed f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Add a label and a button f.getContentPane().add(new JLabel("Hello, world!")); f.getContentPane().add(new JButton("Press me!")); // Arrange the components inside the window f.pack(); // By default, the window is not visible. Make it visible. f.setVisible(true); } public static void main(String[] args) { SwingExample se = new SwingExample(); // Schedules the application to be run at the correct time in the event queue. SwingUtilities.invokeLater(se); } }