How does paintComponent work?

The (very) short answer to your question is that paintComponent is called “when it needs to be.” Sometimes it’s easier to think of the Java Swing GUI system as a “black-box,” where much of the internals are handled without too much visibility. There are a number of factors that determine when a component needs to … Read more

Difference between paint, paintComponent and paintComponents in Swing

AWT, override paint(). Swing top-level container (e.g.s are JFrame, JWindow, JDialog, JApplet ..), override paint(). But there are a number of good reasons not to paint in a TLC. A subject for a separate question, perhaps. The rest of Swing (any component that derives from JComponent), override paintComponent(). Neither override nor explicitly call paintComponents(), leave … Read more