aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes rotating custom button, what paint method to ovveride Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "rotating custom button, what paint method to ovveride " Watch "rotating custom button, what paint method to ovveride " New topic
Author

rotating custom button, what paint method to ovveride

Ned Perez
Greenhorn

Joined: Nov 18, 2011
Posts: 10
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




[Thumbnail for buttonPressed.PNG]


[Thumbnail for buttonDefault.PNG]

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
there's lots of google examples of rotating images.
I'd start there, and see how it's done in the sample codes available.
Ned Perez
Greenhorn

Joined: Nov 18, 2011
Posts: 10
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.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

hmm...
they must have changed it because when i search i get:
Nothing found in All Locations for query "src.zip"


SCJP
Visit my download page
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

I have the latest versions of JDK 6 and JDK 7 installed, and both have the src.zip file. You are checking the JDK folder and not the JRE folder, right?
Ned Perez
Greenhorn

Joined: Nov 18, 2011
Posts: 10
thank you Rob i just found the paintIcon method of BasicButtonUI, i can still leave my class as a BasicButtonUI child..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rotating custom button, what paint method to ovveride