In swing-java, where did the Graphics instance come from?

When an update request is delivered to swing (either from a system called, for example, due to resizing or blocking by another window, or using an application called by calling the repaint () method), how is this request actually processed? What is the procedure in this RepaintManager function?

+6
source share
1 answer

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.

+3
source

Source: https://habr.com/ru/post/915511/


All Articles