TransJam Collaboration Server

TransJam Client Programming Tutorial

Home Documentation Chat Demo WebDrum

Using an AppletTester

An Applet is normally run inside a web browser. But developing Java code is faster when using an IDE (Integrated Development Environment) such as Borland JBuilder. Luckily we can write our Applets in such a way that we can run them from the IDE during development, and then put them in a web page once they are debugged.

We can use a special class called AppletTester that is part of the "com.transjam.awt" package. This package contains a set of AWT based GUI  tools for use with the Transjam server. The AppletTester simulates the web browser environment and calls our Applet just like a web browser. It creates a Frame and places the Applet in the center of the frame. Then it calls the Applet's init() and start() methods. When the frame is closed, the Applet's stop() and destroy() methods are called.

In order to run an application from an IDE, we must provide a main() method. In the main method we instantiate one of our Applet objects. Then we pass it to a static method of the AppletTester.

/** Define main() so that we can test this Applet like a regular application.
 *  Then we can debug it using an IDE instead of a browser.
 */
    public static void main( String argv[] )
    {
    // Create one of these objects.
        Chatter applet = new Chatter();
    // Test the applet using this browser simulator.
        AppletTester.test( applet, 500, 400 );
    }
[Previous] [Top] [Next]

(C) 2002 SoftSynth.com