How to change an applet background color?

Applet’s default background color is Grey. If you want to change it then you need to call the setBackground(java.awt.Color) and choose the color you want. Defining the background color in the init method will change the color as soon as the applet initialized.

 * Created on 08-2011 Copyright(c) All Rights Reserved.

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

 * Created by
 * Date: 8/26/11
public class ChangeAppletBgk extends Applet{
    public void init(){

    public void paint(Graphics graphics){
        graphics.drawString("Applet background example", 0, 50);

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.