Computer Science 523
Advanced Programming

Summer 2014, The College of Saint Rose

HelloWorldApplet Demo

A working demo of HelloWorldApplet will appear below. Click inside the applet to interact with it.



HelloWorldApplet BlueJ Project

Click here to download a BlueJ project for HelloWorldApplet.


HelloWorldApplet Source Code

The Java source code for HelloWorldApplet is below. Click on a file name to download it.


HelloWorldApplet.java


/*
 * Example HelloWorldApplet: an incredibly simple JApplet
 *
 * Jim Teresco, The College of Saint Rose, CSC 523, Summer 2014
 *
 * $Id: HelloWorldApplet.java 2379 2014-06-17 03:52:55Z terescoj $
 */

// as with other Java API classes, JApplet and other classes
// we will use are specified in import statements.
import javax.swing.JApplet;
import javax.swing.JLabel;

// an applet needs to be a special case of a JApplet - this is
// a Java API class that knows how to create a graphical window
// where we can place widgets like labels, buttons, text fields,
// etc, and can interact using the mouse and keyboard.
public class HelloWorldApplet extends JApplet {

    // Applets don't start executing in a main method, they
    // are started by executing an init method in a JApplet class
    public void init() {
	
        // We will see that we can create many Swing components,
        // perhaps the simplest of which is the JLabel.  This is
        // just a static piece of text you can display in your window.
        // JApplet has an add method that we can use to place
        // our Java Swing components into our GUI window.x
        add(new JLabel("Hello, Applet World!"));
    }
}