101 Program to set background and foreground color of Applet in Java

Code:

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;

public class Back extends Applet
{
public void init()
{
setBackground(Color.red);
setForeground(Color.blue);
}

public void paint( Graphics g )
{
g.drawString(" Welcome to Coding Atharva ",10,100);
}
}

/*
<applet  code="Back" height=200 ; width = 200 >
</applet>
*/




Ouput:

Welcome message in Applet in Java


Previous
Next Post »