Applets use a default background of gray, which may not be visually appealing to you. Besides, gray may be the background color of the web page on which the applet is loaded.
One way to change the applet’s background is to repaint the background in the paint() method of the applet. But, if you wanted to change the applet’s background as soon as the applet loads, the best place would be in the init() method, and the applet will change color once it’s loaded, as in the following:
public void init() { setBackground ( Color.black ); //rest of the init() code }