This is the first swing example

import java.awt.*;
import java.applet.*;
import javax.swing.*; // Using swing
import java.awt.event.*; // using listeners

public class FirstSwing extends JPanel {
    // this is an application: need main
    public static void main(String[] args) {

	// setting up the frame, give it a title
	JFrame fr = new JFrame("First swing example");

	// get the frame's content pane:
	Container cp = fr.getContentPane();

	// create and initialize a FirstSwing object
	FirstSwing fs = new FirstSwing();

	// add the object to the frame
	// display the frame (after the object is added)

    // the method initializes the FirstSwing object
    public void init() {
	JLabel label = new JLabel("Hi There!");

This is an example from CSci 2101 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.