• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rotating custom button, what paint method to ovveride

 
Ned Perez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

buttonPressed.PNG
[Thumbnail for buttonPressed.PNG]
pressed button image
buttonDefault.PNG
[Thumbnail for buttonDefault.PNG]
default button image
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Randall Twede
Ranch Hand
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm...
they must have changed it because when i search i get:
Nothing found in All Locations for query "src.zip"
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Rob i just found the paintIcon method of BasicButtonUI, i can still leave my class as a BasicButtonUI child..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic