• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

rotating custom button, what paint method to ovveride

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
reply
    Bookmark Topic Watch Topic
  • New Topic