com.jgoodies.uif.osx
Class OSXApplicationMenu

java.lang.Object
  extended by com.jgoodies.uif.osx.OSXApplicationMenu

public final class OSXApplicationMenu
extends Object

Hooks existing about, preferences and quit action listeners into the Mac OS X application menu. Provides information which functions have been hooked into the application menu, so an application can request this if it conditionally builds menus. Reduces the effort to support these Mac OS X features in multi-platform applications.

The implementation first checks for a Mac OS X Java runtime and does nothing if it runs on a different platform. Next, it tries to load a subclass of the ApplicationAdapter from the Mac Java extensions in package com.apple.eawt.

Since:
1.3
Version:
$Revision: 1.5 $
Author:
Karsten Lentzsch
See Also:
OSXApplicationHandler

Method Summary
static boolean isRegisteredAbout()
          Checks and answers whether an about listener has been registered with the Mac OS X application menu.
static boolean isRegisteredPreferences()
          Checks and answers whether a preferences listener has been registered with the Mac OS X application menu.
static boolean isRegisteredQuit()
          Checks and answers whether a quit listener has been registered with the Mac OS X application menu.
static boolean register(ActionListener about, ActionListener preferences, ActionListener quit)
          Registers the given action listeners for about, preferences and quit with the Mac OS X application menu - if we're on OS X.
static void setAboutName(String aboutName)
          Sets the name that is used in the Mac OS X application menu as title and suffix for the about and quit actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setAboutName

public static void setAboutName(String aboutName)
Sets the name that is used in the Mac OS X application menu as title and suffix for the about and quit actions. Catches an AccessControlException silently in case this method has been invoked in an untrusted environment.

Must be called before a windows is opened. And so, a good place is the application's main method or the application startup. AbstractUIFApplication#load calls this method.

Parameters:
aboutName - the name to be used

register

public static boolean register(ActionListener about,
                               ActionListener preferences,
                               ActionListener quit)
Registers the given action listeners for about, preferences and quit with the Mac OS X application menu - if we're on OS X.

Parameters:
about - a listener that performs the about action
preferences - a listener that performs the preferences action
quit - a listener that performs the quit action
Returns:
true if an action has been registered

isRegisteredAbout

public static boolean isRegisteredAbout()
Checks and answers whether an about listener has been registered with the Mac OS X application menu. Useful to conditionally build a menu item for About.

Returns:
true if an about listener has been registered

isRegisteredPreferences

public static boolean isRegisteredPreferences()
Checks and answers whether a preferences listener has been registered with the Mac OS X application menu. Useful to conditionally build a menu item for Preferences.

Returns:
true if a preferences listener has been registered

isRegisteredQuit

public static boolean isRegisteredQuit()
Checks and answers whether a quit listener has been registered with the Mac OS X application menu. Useful to conditionally build a menu item for Quit/Exit.

Returns:
true if a quit listener has been registered


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.