All right real quick question guys. I know that C# Forms have the OnPaint() method that keeps on being called when its time to render. I know Java has a similar one but I am lost on how to implement it. Any pointers or example(prefferred) will be very much appreciated. Thanks a lot.
Asked
Active
Viewed 1,118 times
1
-
please specify whether your context: awt or swing? – kleopatra Nov 08 '11 at 14:47
2 Answers
2
If using Swing, refrain from painting in a top level container (e.g. JApplet
or JFrame
) and use a JComponent
or JPanel
.
For custom painting in the latter two classes, use paintComponent(Graphics)
.

Andrew Thompson
- 168,117
- 40
- 217
- 433
-
Glad you got it sorted! Was going to 'chide' you for *"real quick question"* explaining that answers are sometimes harder (i.e. not as quick) than questions. I instead chose to throw you some basic tips ('search terms' if you like) and see if you could capitalize on my 'quick answer'. Nice to see you were able to figure it out on your own. :) – Andrew Thompson Nov 12 '11 at 04:21