Applet to UIApplet

To convert from AWT to AFC, instances of java.applet.Applet should be transformed into instances of com.ms.ui.UIApplet.

Applet extends Panel: be sure to see its changes.

Purpose and Usage

AFC's UIApplet is designed to take advantage of the improved component model without creating a difficult situation for a developer. Because browsers and applet viewers expect applets, not UIApplets, you need to wrap an applet (written normally, extending UIApplet) in a class extending AwtUIApplet, which acts as a bridge between AWT and UI components. This is a simple process. As an example, here is the "Hello World" applet, in a basic AWT version and then in a UI version.

Basic AWT version:

import java.applet.*;
import java.awt.*;

public class HelloWorld extends Applet
{

public void init()
{

setSize(150,25);

}

public void paint(Graphics g)
{

g.drawString("Hello World",50,25);

}

}

A UI version of the same applet (with the differences in red)

import java.applet.*;
import java.awt.*;

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

public class HelloWorld extends AwtUIApplet
{

public HelloWorld()
{

super(new HelloWorldImpl());

}

}

 

class HelloWorldImpl extends UIApplet
{

public void init()
{

setSize(150,25);

}

 

public void paint(FxGraphics g)
{

g.drawString("Hello World",50,25);

}

}

 

Porting

This is the set of changes you need to make to port all Applet methods to UIApplet methods. Any method not listed here or below does not need to be changed.

 

AWT Code AFC Code
Applet() UIApplet()
resize(Dimension) or
setSize(Dimension)
setSize(Dimension)

 

Unsupported Methods

Some methods in java.applet.Applet are not directly supported in com.ms.ui.UIApplet. Those methods are listed here.

getLocale()

setStub(AppletStub)