Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information

Java Cup Logo

JDC Home Page


Working Applet
Help and Hints
Source Code
Table of Contents
Online Training
shadowSearchFAQFeedback

Solution

Download CheckboxTest source code.

HTML Interface to Applet


<APPLET CODEBASE="/applets/magelang/AWT-Training/classes/" CODE="CheckboxTest.class" WIDTH=300 HEIGHT=30 ALIGN=CENTER></APPLET>

Java Code


import java.awt.*;

public class CheckboxTest extends java.applet.Applet {

    public CheckboxTest() {
        MyCheckbox m = new MyCheckbox();
        add(m);
    }
}

class MyCheckbox extends Checkbox {

    public MyCheckbox() {
        super("Always Prompt");
    }

    public boolean action(Event e, Object state) {
        System.out.println("State is " + (Boolean) state);
        return true;
    }
}