i have been frequently doing some basic swing animations(shapes), using particularly a swing Component JPanel, but now i'm dealing with a custom button , i was once trying to, ofcouse creating a custom button and google didnt disappoint me, but as i try to think more creative UIs, i decided to make this custom a rotating one. When using a JPanel, overriding the paint methods, using runnable interface or Timer tasking and painting the desired image , a rotating can be done by a Transforming approach(AffineTransform), but as i look on my codes(custom button, code below), i was surprised that i CANNOT find how the icon is being painted into the custom button
my questions are
- how does the setIcon methods paint the Image that im passing, setPressedIcon(<Icon>), setRollOver(<Icon>) methods
- what method should i override from BasicButtonUI to locate where does the painting happen, so i will be able to control the painting , do some Timer tasking and AffineTransforming to make a smooth rotating Button
there's lots of google examples of rotating images.
I'd start there, and see how it's done in the sample codes available.
Joined: Nov 18, 2011
yes, i already seen and tested those sample codes, and that is where i also got this code that i posted, i really just want to understand how does the buttonUI paints the images into the button, if i will be able to locate the method and override it, i might be able to do the the rotating painting into the button itself.
You can check out the default UI; it's javax.swing.plaf.metal.MetalButtonUI which extends javax.swing.plaf.basic.BasicButtonUI. You can find the source of both in the src.zip file in the JDK root folder.