From your comment:
Do you know what happens in peer.getGraphics ()?
It depends on which implementation is used for reconciliation.
One implementation is WComponentPeer
(used on Windows), which apparently uses two methods to get a Graphics
object:
If the component has a parent type of Window
(or by itself), which, in turn, is associated with a back buffer, this Graphics
object is returned. It depends on the type of image, but it most SunGraphics2D
resembles the instance of SunGraphics2D
created in createGraphics()
.
Otherwise, an instance of ScreenUpdateManager
is retrieved and createGraphics(...)
is called, which in turn returns a new instance of SunGraphics2D
.
Please note that this is just one of the possible ways, and it depends a lot on the OS, the JVM and UI tools used.
source share