The Java Program: HelloSwing.java
1 import javax.swing.JFrame;
2 import javax.swing.JLabel;
3
4 public class HelloSwing {
5
6 private static void createAndShowGUI () {
7 final JFrame frame = new JFrame ("Hello Swing");
8 final JLabel label = new JLabel ("Hello Swing");
9 frame.getContentPane().add(label);
10 frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
11 frame.pack();
12 frame.setVisible(true);
13 }
14
15 public static void main (String [] args) {
16 javax.swing.SwingUtilities.invokeLater (new Runnable() {
17 public void run () { createAndShowGUI(); }
18 });
19 }
20 }