I come from an Objective-C background and I have been developing on the iOS and Mac OS platform for a number of years now. I love the concept of custom drawing and therefore I would like to replicate what had been done by me on the aforementioned platform.
In iOS I would call -drawRect()
to draw a custom view and then, I could go ahead and add other visual components on top of that drawing. I know that there are equivalents in java swing and awt called paint()
and paintComponent()
. However, I am not quite sure how the drawing goes about. I do not know when to call the super method (beginning or end ?) and how to add other components to the custom drawn component (custom drawing sometimes appears on top, sometimes beneath).
Can someone shed some light on this ?
I have already read up a little bit on when to use what, but I am still not 100% sure, so can anybody explain when exactly to use paint()
and when paintComponent()
?
Start with the java tutorials.
http://docs.oracle.com/javase/tutorial/uiswing/painting/index.html