The setBackground() method is defined by the Component class. It is used to set the background of an applet’s window to a specified color. The syntax of this method declaration is as follows:
Here, new color specifies the color. The Color class defines the constants, which can be used to set the color. Some of them are listed below:
- Color.black
- Color.pink
- Color.green
- Color.yellow