aspose file tools*
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
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: 2227
    
    8
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does the repaint() method run the paintComponent() method automatically?