PDA

View Full Version : paintComponent in java 2011



saneha
04-24-2011, 10:01 PM
Respected Sir A.A,

in the Example code 18.1, while overriding the paintComponent method of the myPanel class, you call the parent paintComponent method (super.paintComponent), i didn't understand this that why u did this????????

Vuhelper
04-24-2011, 10:02 PM
We use super.paintComponent(g) to clear the background of our panel. As there is nothing in the paintComponent() method of the parent class. So to make the background blank we will call the method of parent class, which will draw blank or simply clear every thing.



We are using super so that paintComponent() of parent class is called.