Originally Posted by Garaen
I imagine that much of the mechanics of paintComponent are to be found in Container, but I haven't looked at the source to know exactly what does what.
Edit: JPanel doesn't even have a paintComponent method much less a paint method.
... JComponent which seems to override that method from its superclass Container (right?)
No. If you look at the Container API you'll see that it has no such method. The paintComponent method originates in JComponent.
- the paintComponent() from JComponent creates a Graphics variable and calls create()
I thought that the Graphics object came directly from the JVM.
Edit: the Graphics used to paint any UI delegates is created in JComponent's paintComponent method by copying the Graphics object passed in by the JVM, and then disposes this Graphics object once the UI delegates have been painted.
Have you had a look at one of my favorite articles on Swing graphics?: Painting in AWT and Swing
. It's well worth a study.