void (VolatileImage vi) { Graphics2D g = (Graphics2D)vi.getGraphics().create(); try { g.setBackground(Gray.TRANSPARENT); g.setComposite(AlphaComposite.Src); g.clearRect(0, 0, myComponent.getWidth(), myComponent.getHeight()); drawContent(g); } finally { g.dispose(); } }