Thanks for reply, as I am quite new to Java, please explain it more detail. As I understand, main method is the default method to run in Java project. How about in this case? In which way it is getting called?? BTW I not write this code myself
Joined: Mar 22, 2005
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, but as I said, you should not write code that way. If you're learning Swing, I suggest to start by changing this code to override paintComponent instead of paint (and, of course, read the links I posted if you haven't done so yet).
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