please explain it more detail
If you want to know the details, then you need to do the reading yourself. Ulf, gave you two execellent links that explain how painting works. So take the time to read them both. The first gets into the technical detail of painting, the second is more practical and gives you an example to learn from. Once you read the articles if there is something you don't understand then you can ask a specific question about something you read, but we are not going to read and summarize the article for you.
The paintComponent method is the method that gets called whenever the JVM decides that a Swing component should be drawn. It will in turn cause paint to be called
Actually it is the other way around paint() will invoke paintComponent(). See:
A Closer Look at the Painting Mechanism
Basically