Rendering Components

Components are rendered in the paint(Graphics) method, which is typically invoked under one of the following circumstances:

  1. A system paint or update event is generated

  2. An explicit call to repaint() is made

System paint and update events are generated whenever the component needs to be repainted as a result of manipulation of manipulating the window in which it resides. For example, if an applet window is covered by another window and subsequently brought to the front, a PaintEvent is generated and sent to the components within the applet that need to be repainted.

repaint() is often invoked explicitly, sometimes by the component itself, when the component's graphical representation changes. Component.repaint() is overloaded ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.