code: private void paintWithCaching(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) {
          VolatileImage img = getImage(g.getDeviceConfiguration(), c, w, h, extendedCacheKeys);
  
          if (img != null) {
  
              // render cached image
              g.drawImage(img, 0, 0, null);
          } else {
  
              // render directly
              paintDirectly(g, c, w, h, extendedCacheKeys);
          }
      }
docs: Paint the component, using a cached image if possible.
  
  @param g                 the Graphics2D context to paint with.
  @param c                 the component to paint.
  @param w                 the component width.
  @param h                 the component height.
  @param extendedCacheKeys extended cache keys.