Sunday, July 4, 2010

Applet Example

This is an example Applet Java Code:

import java.awt.*;
import java.applet.*;
public class Sample extends Applet
{

String msg;

// set the foreground and background colors.
public void init()
{
setBackground(Color.cyan);
setForeground(Color.red);
msg = "Inside init( ) ";
}

public void start()
{
msg += " Inside start( ) ";
}

// Display msg in applet window.

public void paint(Graphics g)
{
msg += " Inside paint( )";
g.drawString(msg, 10, 30);
}
}

No comments:

Post a Comment