Application Foundation Classes
 
 

AFC    PreviousAFCNext
Microsoft Application Foundation Classes (AFC)     Previous AFC Next

 


AFC Skeleton




// AFCSkeleton.java
//
// A minimal AFC application skeleton designed to function 
// as an applet or as a stand-alone application.

import java.awt.*;
import com.ms.ui.*;
import com.ms.fx.*;

// Bridge class for AFC applet
public class AFCSkeleton extends AwtUIApplet
{
    // Constructor
    public AFCSkeleton ()
    {
        // Create instance of applet implementation
        super (new AFCSkeletonImplementation ());
    }
    
    // Stand-alone application entry point
    public static void main(String args[])
    {
        // Create a frame to contain applet
        AFCSkeletonFrame f = new AFCSkeletonFrame ("AFC Skeleton Application");
        f.setVisible (true);
        f.setSize (320, 200);

        // Create instance of applet implementation and add to frame
        AFCSkeletonImplementation applet = new AFCSkeletonImplementation ();
        f.add (applet);

        // Stand-alone application must explicitly call init() 
        applet.init ();
    }

    // Add pass-through methods for scriptable applet methods here
    public String getInfo () {return (((AFCSkeletonImplementation) getUIApplet ()).getInfo ());}
}

// Class for applet implementation
class AFCSkeletonImplementation extends UIApplet
{
    // Applet entry point
    public void init()
    {
        setBackground (FxColor.cyan);

        // Add additional components here
    }

    public String getInfo ()
    {
        String s = "Info about AFCSkeleton.class\r\n";
        s += "Version: 1.0\r\n";
        return s;
    }
}

// Stand-alone application only.
class AFCSkeletonFrame extends UIFrame
{
    // Constructor
    public AFCSkeletonFrame(String str)
    {
        super (str);
    }

    public boolean handleEvent (Event e)
    {
        switch (e.id)
        {
        case Event.WINDOW_DESTROY:
            // Frame window closed, exit app
            System.exit (0);
            return true;
        default:
            return super.handleEvent (e);
        }
    }
}

Top © 1998 Microsoft Corporation. All rights reserved. Terms of use.