void () { Dimension size = myContent.getPreferredSize(); Rectangle bounds = myContent.getBounds(); applyDoubledBuffered(myContent, false); //myContent.setDoubleBuffered(false); myContent.setBounds(0, 0, size.width, size.height); myContent.validate(); //noinspection UndesirableClassUsage myImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); final Graphics2D graphics = myImage.createGraphics(); UISettings.setupAntialiasing(graphics); graphics.setClip(0, 0, size.width, size.height); graphics.setColor(UIUtil.getListBackground()); graphics.fillRect(0, 0, size.width, size.height); myContent.paint(graphics); graphics.dispose(); int expectedDurationMillis = 500; myAnimationIterationStep = Math.max( (myHorizontal ? size.width : size.height) / (expectedDurationMillis / ArrangementConstants.ANIMATION_STEPS_TIME_GAP_MILLIS), 1); myContent.setBounds(bounds); applyDoubledBuffered(myContent, true); if (myExpand) { if (myHorizontal) { myCurrentImage = myImage.getSubimage(0, 0, myAnimationIterationStep, myImage.getHeight()); } else { myCurrentImage = myImage.getSubimage(0, 0, myImage.getWidth(), myAnimationIterationStep); } } else { if (myHorizontal) { myCurrentImage = myImage.getSubimage( 0, 0, myImage.getWidth() - myAnimationIterationStep, myImage.getHeight() ); } else { myCurrentImage = myImage.getSubimage( 0, 0, myImage.getWidth(), myImage.getHeight() - myAnimationIterationStep ); } } invalidate(); }