
414
|
Chapter 11, Native Integration and Packaging
#81 Make Mac Applications Behave Normally
HACK
To smooth over the cross-platform differences somewhat, Apple does cer-
tain things differently in its Java implementation. For one thing, it will auto-
matically put a Swing application into its native Look and Feel, Aqua, rather
than defaulting into cross-platform Metal or Ocean as would happen on
other platforms. In other words, you don’t have to do anything special to
pick up the Mac Look and Feel, although redundantly asking for and set-
ting the native Look and Feel classname doesn’t hurt either.
Moreover, Apple provides some key/value pairs that you can set in the Java
system properties to get even more Mac-like behavior. Because these proper-
ties all start with
apple or com.apple, you can set them and not worry that
they’ll affect the behavior of your application on any other platform.
Using the Apple System Properties
Apple has been changing the names and behaviors of these system proper-
ties for a while, and some of them are deprecated or no-op’ed, so I’ll just
show four of the most useful ones here. To see the whole list, check out the
Runtime System Properties of Apple’s Java 1.4.1 release notes on http://
developer.apple.com/releasenotes/Java/index.html.
You can set the properties several ways. The obvious way is to use the
-D
command-line argument:
java -Dapple.awt.showGrowBox=true MyClass ...