How painting is Handled
A java applet or application does its drawing in response to paint events.
(For safety's sake, it should only do its painting in this manner.)
The paint events themselves are of two types--PAINT and UPDATE--reflecting
the fact that these events normally come from different places.
PAINT events
PAINT events are initiated by the window system in response to a change
in the visibility of the window that underlies the java component. For
example, when a window is first put up on the screen, a PAINT event will
be delivered in order to initiate drawing on the window.
UPDATE events
UPDATE events are initiated by the client. They should not be sent
directly; instead, the client calls the component's repaint() method,
which uses a separate thread called the ScreenUpdater to generate the
event at a specified time in the future.
PAINT events are normally processed by the peer first, and then posted
to AWT. (This is in contrast to input events, which are seen by AWT
before the peer gets them.) UPDATE events may be seen by the peer,
but they are simply passed along to AWT: while a PAINT event always
causes a peer to repaint itself, an UPDATE event should never cause a
peer to repaint.
The default implementation of the update() method clears the component
to background, then calls the paint() method--a full repaint. In
other words, it simulates the behavior that the peer exhibits in
response to a PAINT event. Because this code is in an AWT method,
however, the app(let) can override the update() method and avoid the
full repaint. This is useful in implementing partial repaints and
animations that are less prone to "flashing" than they would be with
a complete repaint of the component at every step.
The java PaintEvent class is a subclass of ComponentEvent. This
implies that paint events do not get sent to AWT Menu-related objects.
A Menu or MenuItem will receive PAINT events through the normal means,
but will not propagate them to AWT. It will not receive UPDATE events.
Lightweight components
The painting of lightweight components is handled within AWT. If a
PAINT or UPDATE is received by a container, the corresponding method
of all lightweights inside that container will be called.
Last modified: Fri May 15 16:31:42 PDT