Hey guys,

I've seen very limited examples out there about this unsupported function, however I am sure there must be a quick method to get this done with the Affine Transform ?

Any ideas appreciated.


If you have the image, and are drawing it in a paintComponent method, then you can cast the Graphics g parameter to Graphics2D and use its rotate method. (which is an easier cover method for a rotational AffineTransform)

Thanks for your advice :)

Currently breaking this down, it works great but shorted is always better.

private JLabel lblRover = new JLabel(imageIcon) {
	protected void paintComponent(Graphics g) {
	Graphics2D g2 = (Graphics2D)g;
	AffineTransform aT = g2.getTransform();
	Shape oldshape = g2.getClip();
	double x = getWidth()/2.0;
	double y = getHeight()/2.0;
	aT.rotate(Math.toRadians(angle), x, y);


Shorter is not always better - easier to understand is better. If you have ever had to fix or update someone else's code you would agree. Breaking it down to easy steps is a good thing; the compiler is very good at optimising simple code. Your code is great, don't change it.

This question has already been answered. Start a new discussion instead.