javacodex.com
Java Examples
Java Examples
memu home questions

Hello World

Below is a java swing example for the traditional Hello World program.

Source: (HelloWorld.java)

import javax.swing.*;
 
public class HelloWorld {
 
  public static void main(String[] arguments) {
 
    JLabel label = new JLabel("Hello World");
 
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame f = new JFrame("Hello World");
    f.setSize(300,150);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
    f.add(label);
 
    f.setVisible(true);
 
  }
}
 

Output:

$ java HelloWorld
Output



Contact: javacodex@yahoo.com