This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I basically copied a program from a book and ran it .In the porgram a circle moves from one position to the other slowly .I have a doubt as to how the program is running ,I dont understand how or where the method paintComponent is being called in the program.
That method is called by the JVM is response to various events, eg the GUI becoming visible, coming to the front, being exposed by another object on screen, an invocation of repaint(). It might be worth reading the source of repaint(), too.
You'll never explicitly call paintComponent(g), Java will.
The method repaint() instructs Java to call paintComponent(g) through a series of other calls. This is not explicit however, and is in no way guaranteed.
I recommend Googling about the hierarchy of calls that takes place when repaint() is called, and maybe follow through some painting tutorials.
Joined: May 18, 2011
Thanks a lot for explaining Caleb Kemper,Campbell Ritchie and Michael Dunn .
Campbell Ritchie ,i couldnt quiet get this line ,do you mean that paintComponent should have protected access?
Campbell Ritchie wrote:Shouldn’t is have protected access?