I am unable to understand why the println() statement inside paint() is executing twice.This is the code-
import java.awt.*;
import java.applet.*;
public class FirstApplet extends Applet
{
public void init()
{
System.out.println(getBackground());
}
public void paint(Graphics g)
{
setBackground(Color.CYAN);
setForeground(Color.RED);
g.drawString("This is my first Applet",250,250);
System.out.println(getBackground());
}
}
OUTPUT:
java.awt.Color[r=255,g=255,b=255]
java.awt.Color[r=0,g=255,b=255]
java.awt.Color[r=0,g=255,b=255]
Can somebody please explain me why the println() inside paint() is executing twice?