In Java, when using the paintComponent() method for a JPanel, the parameter that is passed is an object from the abstract class Graphics. Since using an abstract object doesn't make sense, I'm assuming the object that is actually passed is from a concrete subclass of Graphics.
My question is, what 开发者_JAVA技巧is this concrete subclass of Graphics, and where was it generated?
public void paintComponent(Graphics g) { ... }
It should be
sun.java2d.SunGraphics2D which is extended from java.awt.Graphics2D
each top level Component should have a reference to one, and any child components ask their parent for one until the parent can satisfy the request.
精彩评论