This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
John Quach
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that's true, I don't understand how that works.




 
Rob Camick
Ranch Hand
Posts: 2616
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic