I am working on a Java Swing application on OSX and I want it to appear as Mac-Like as possible. I have achieved most of the desired look but one thing still eludes me.
It's the Title Bar. Many native OSX apps have a 'high' title bar with 'toolbar buttons' on it and a small button to toggle show/hide of the 'toolbar buttons' on the top right (see image of FeedForAll application which is Java but uses SWT).
Any ideas how this can be achieved? Any help or pointers would be much appreciated.
In Swing, native OS components are not actually used. The default "Aqua" look and feel on Mac tries to match the native look as well as possible, but it is really just painting things with Java2D. So, for example, the pulsing glow of the default button is not implemented.
There are some client properties you can set on the window to affect its appearance, but the "title toolbar" does not seem to be an option:
http://developer.apple.com/library/mac/#technotes/tn2007/tn2196.html#//apple_ref/doc/uid/DTS10004439
One option would be to switch to using the Quaqua look and feel. I haven't used it myself, but supposedly it is even more faithful to the Mac look than Aqua is. It has a property you can set to get the toolbar appearance you want:
http://www.randelshofer.ch/quaqua/guide/client_properties.html#JToolBar
You might look into the Unified Tool Bar available in Mac Widgets for Java.
Sorry, but I do not think you can get the toolbar control button using Swing. There are no appl-esqe system properties that would draw it for you. Try "apple.awt.brushMetalLook" property, but as far as I remember it just had the unified toolbar and titlebar. SWT seems like your only choice.
Also, I do not think you should worry about this UI element.This button is removed from all OS X user interface elements since 10.7 (Lion)
With Lion, most of the applications have the fullscreen icon on top right. When using Swing for OS X programming I think you should draw a line at some point in your quest to get it looking absolutely native.
To add to that, I think Mozilla clients are developed in Objective C/C++ and some Java (may be) for Mac.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With