void (Component component, Graphics2D g) { if (!nrp.get()) return; long currentTimeMillis = System.currentTimeMillis(); float alpha = 1 - (float)frameIndex / TOTAL_FRAMES; g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); Image scaledImage = ImageUtil.scaleImage(myImage, alpha); int x = myExplosionLocation.x - scaledImage.getWidth(null) / 2; int y = myExplosionLocation.y - scaledImage.getHeight(null) / 2; if (currentTimeMillis - lastRepaintTime < TIME_PER_FRAME) { UIUtil.drawImage(g, scaledImage, x, y, null); EdtExecutorService.getScheduledExecutorInstance().schedule(() -> component.repaint(x, y, myWidth, myHeight), TIME_PER_FRAME, TimeUnit.MILLISECONDS); return; } lastRepaintTime = currentTimeMillis; frameIndex++; UIUtil.drawImage(g, scaledImage, x, y, null); if (frameIndex == TOTAL_FRAMES) { nrp.set(false); ApplicationManager.getApplication().invokeLater(() -> Disposer.dispose(myPainterListenersDisposable)); component.repaint(x, y, myWidth, myHeight); } component.repaint(x, y, myWidth, myHeight); }