public static void setPreferencesHandler(Object target, Method prefsHandler) {
        boolean enablePrefsMenu = (target != null && prefsHandler != null);
        if (enablePrefsMenu) {
            setHandler(new OSXAdapter("handlePreferences", target, prefsHandler));
        }
        // If we're setting a handler, enable the Preferences menu item by calling
        // com.apple.eawt.Application reflectively
        try {
            Method enablePrefsMethod = macOSXApplication.getClass().getDeclaredMethod("setEnabledPreferencesMenu", new Class[] { boolean.class });
            enablePrefsMethod.invoke(macOSXApplication, new Object[] { Boolean.valueOf(enablePrefsMenu) });
        } catch (Exception ex) {
            System.err.println("OSXAdapter could not access the About Menu");
            ex.printStackTrace();
        }
    }
public static void setPreferencesHandler ( Object target , Method prefsHandler ) { boolean enablePrefsMenu = ( target != null && prefsHandler != null ) ; if ( enablePrefsMenu ) { setHandler ( new OSXAdapter ( "handlePreferences" , target , prefsHandler ) ) ; } try { Method enablePrefsMethod = macOSXApplication . getClass ( ) . getDeclaredMethod ( "setEnabledPreferencesMenu" , new Class [ ] { boolean . class } ) ; enablePrefsMethod . invoke ( macOSXApplication , new Object [ ] { Boolean . valueOf ( enablePrefsMenu ) } ) ; } catch ( Exception ex ) { System . err . println ( "OSXAdapter could not access the About Menu" ) ; ex . printStackTrace ( ) ; } }
They will be called when the Preferences menu item is selected from the application menu