/* * A simple Java program that displays some text in a window. * Compile with: "javac HelloWorldGUI.java" * Run with: "java HelloWorldGUI" * * Ben Bederson, January 16, 2002 */ import java.awt.*; import javax.swing.*; public class HelloWorldGUI extends JFrame { public HelloWorldGUI() { // Create a window setTitle("Hello world!"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a "label" component JLabel label = new JLabel("Hello world!"); label.setForeground(Color.blue); label.setFont(new Font("Arial", Font.BOLD, 24)); // Insert the label into the window getContentPane().add(label); getContentPane().setBackground(Color.white); pack(); // Calculate the size of the window setVisible(true); // Make the window visible } public static void main(String[] args) { new HelloWorldGUI(); } }