Chapter 11, Native Integration and Packaging
#81 Make Mac Applications Behave Normally
AWT windows will always use the Mac menu bar.
One thing worth mentioning is that if your application uses different menus
in its various windows, this will still seem strange to Mac users, as the menu
bar will change based on which of your application’s windows has focus.
But to be truly Mac-like, you’d have to have the same menu bar all the time,
which on Windows/Linux might mean having completely inappropriate
menus in some windows. Then again, with good design—and probably
ResourceBundles—you should be able to provide an appropriate menu
bar experience to all your users.
Presenting an Appropriate Application Name
On Mac OS X, the first two items (reading left to right) on the menu bar are
the Apple menu, which controls the whole system (Software Update,
Restart, Log Out, etc.), and the Application menu. The Application menu is
meant to contain items relevant to the entire application: an about box, pref-
erences, the ability to hide itself or other applications, and Quit. But the
menu isn’t named Application; instead, it shows the current application’s
name. That’s great for something short and memorable like Mail or Firefox.
But for a Java application, it picks up the name of the application’s
class. And when you package your code (like you’re supposed to, with the
inverted Internet address style), you get a monstrosity like Figure 11-3.
Fortunately, you can rein in the insanity with the
property. Just set this to the name you want to show
in the application menu. For example, setting it to MyDemo produces the
much more reasonable application menu seen in Figure 11-4.
Figure 11-3. A long Java classname as a Mac application name