What is the purpose of calling superpaintg at the beginning
What is the purpose of calling super.paint(g) at the beginning of a JFrame’s paint function?
It makes sure all the drawing tasks, like g.drawOval, are performed.
It makes sure that the Graphics object is created so that we can draw on it.
It makes sure that the background and borders and outlines of graphical user interface components are drawn.
It reduces memory leaks associated with drawing shapes on the screen.
Solution
Answer:
It makes sure that the Graphics object is created so that we can draw on it.
public void paint(Graphics g){
super.paint(g);
}
super.paint(g) should be called so that Swings/lightweight components are properly rendered.
