record
Records block's drawing into a transparent buffer of width x height user-space units, replacing whatever this layer held.
The buffer is sized in device pixels - width and height multiplied by scale, rounded up - and the Graphics2D handed to block is pre-scaled and clipped to the buffer, so block draws in user-space coordinates and size reports the user-space size whatever the scale. A block that throws leaves this layer holding what it held before.
Parameters
the width of the recording in user-space units; must be positive.
the height of the recording in user-space units; must be positive.
the device pixels per user-space unit; must be positive. Defaults to 1.0.
draws the recording; the Graphics2D it receives belongs to this call and must not be retained.
Throws
Records what block paints within width x height into device pixels aligned to the pixels it would paint on destination, under the destination's transform and clip, replacing whatever this layer held.
block receives a Graphics2D carrying destination's transform, clip, font, colors and rendering hints, so the content keeps its sub-pixel position at any transform and lands on the same pixels here as it would on destination. The recording covers the device pixels of the area the clip leaves. Where the clip or the size leaves nothing to paint, block does not run and this layer is left empty. A block that throws leaves this layer holding what it held before.
draw draws such a recording back onto the device pixels it was recorded for, whatever transform the graphics it is drawn onto carries.
Parameters
the graphics the recording is aligned to; left as it was found.
the width of the area block paints, in destination's coordinates.
the height of the area block paints, in destination's coordinates.
paints the content; the Graphics2D it receives belongs to this call and must not be retained.
Records component and its descendants at the bounds the component already carries, replacing whatever this layer held.
Nothing is laid out: a component the composition holds carries the bounds its declaration gave it, which a layout pass here would overwrite. A component built by hand has none, so size it first.
A component that was never shown is captured with its pixels.
The component is recorded as it prints: isPaintingForPrint answers true while it paints, so a component that paints differently for print records that way, such as a JTable, which leaves out its selection and focused cell.
Parameters
the component to capture; must have a positive width and height.
the device pixels per user-space unit; must be positive. Defaults to 1.0.
See also
Throws
if called off the event dispatch thread.