Sunday, September 14, 2008

Leopard-like toolbar buttons in Java Swing - part 2

I had been trying to create "leopard-like" toolbar buttons. This required a lot of Swing coding and a bit of imagination. Apple, with its Apple JDK 1.6 features, has introduced ways to create many different kinds of Apple buttons. Namely : square, gradient, bevel, textured, roundrect, recessed and help.
 This greatly reduces the work that you need to do. However, the look will not carry forward to other platforms. For that, you need to paint your own buttons as I mentioned in my earlier blog.
The technique for rendering leopard like toolbar button is :
  • Create a transparent PNG icon for the button - for example, a plus sign
  • Create a JButton and set button.putClientProperty("JButton.buttonType", "segmentedTextured") and various other options in apple's technical note website.


No comments: