anyone here knows how to rotate an icon in Java?

Recommended Answers

All 5 Replies

I don't, but this guy does :)

lol, yeah i searched that on google before posting here.. that code looks way shabby..
maybe Icon() cant be rotated after all..?

btw, i know how to rotate using BufferedImage but i was specifically wondering about Icon.

AffineTransform.
You create an instance of AffineTransform that maps the rotation you want and apply that to a Graphics2D instance with setTransform(...). Paint your icon to the Graphics2D and hey-presto, you have a rotated icon.
Here's a quick intro:
http://www.javareference.com/jrexamples/viewexample.jsp?id=88

thanks bro, much appreciated! will check it out in a bit and let you know if the problem got resolved..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.