HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Application Foundation Classes"
Volume: 2 Issue: 7, p.14

	

Listing 1: How to create a shell AFC applet.

// Listing 1: A shell AFC applet. Use this as a template for building your own AFC applets.

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

public class AFCAppletShell extends UIApplet { 
  public init() { 
    setBackground(FXColor.gray);
    // Add other user interface components here
  } 
}

Listing 2: HTML required to embed the AFC Applet.

<HTML>
<TITLE>A Shell AFC Applet</TITLE>
<CENTER>An Example AFC Applet</CENTER>
<APPLET CODE=AFCAppletShell.class
        ID=AFCAppletShell
        WIDTH=200
        HEIGHT=200>
</APPLET>
</HTML>

Listing 3: How to create a shell AFC applet.

// Listing 3: A shell AFC application. Use this as a template 
// for building your own AFC applications.

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

public class AFCAppShell extends UIApplet
  public static void main(String args[])
    AFCShellFrame frame = new
      new AFCShellFrame("AFC Application Shell");
    frame.show();
    frame.resize(200,200);

    AFCAppShell applet = new AFCAppShell();

    // Add the applet to the frame
    frame.add(applet);

    applet.init();
  }

  public init() {
    setBackground(FXColor.gray);
    // Add other user interface components here
  }
}

class AFCShellFrame extends UIFrame {
  // Frame constructor
  public AFCShellFrame(String str) 
    super(str);
  }

  // Frame event handler
  public boolean handleEvent(Event evnt){
    switch(evnt.id) {
      // Close the application
      case Event.WINDOW_DESTROY:
       System.exit(0);
       return(true);
      // Pass all
other events to the UIFrame
      // event handler
      default:
       super.handleEvent(evnt);
    }
  }
}


}


 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.