/** Disposes of all resources associated with a particular instance of the PaintExample. */ public void dispose() { if (paintSurface != null) paintSurface.dispose(); if (paintColors != null) for (int i = 0; i < paintColors.length; ++i) { final Color color = paintColors[i]; if (color != null) color.dispose(); } paintDefaultFont = null; paintColors = null; paintSurface = null; freeResources(); }