Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes Does the repaint() method run the paintComponent() method automatically? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Does the repaint() method run the paintComponent() method automatically?" Watch "Does the repaint() method run the paintComponent() method automatically?" New topic
Author

Does the repaint() method run the paintComponent() method automatically?

John Quach
Ranch Hand

Joined: Sep 28, 2011
Posts: 50
If that's true, I don't understand how that works.




Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2155
    
    7
Your question and posted code don't make any sense.

The paintComponent() method is used by Swing components, not AWT components. Your example is for an AWT applet.

Swing applets should never be written this way. When creating a Swing applet you would extend JApplet. If you wanted to do custom painting you would override the paintComponent() method of a JPanel (or JComponent) and then add the panel to the content pane of the applet.

The repaint() method will invoke paint(). In a Swing application the paint() method is responsible for invoking paintComponent() along with other methods. See Painting in AWT and Swing for a detailed explanation.
 
wood burning stoves
 
subject: Does the repaint() method run the paintComponent() method automatically?
 
Similar Threads
randomly select colors from Applet
Threads from Java Tutorial
Q about threads: current thread in run( ) method
Applet not displaying icon
sleeping state