下面列出了怎么用java.awt.desktop.PreferencesHandler的API类实例代码及写法,或者点击链接到github查看源代码。
synchronized void setHandler(final PreferencesHandler handler) {
super.setHandler(handler);
_AppMenuBarHandler.getInstance().setPreferencesMenuItemVisible(handler != null);
_AppMenuBarHandler.getInstance().setPreferencesMenuItemEnabled(handler != null);
}
void performUsing(final PreferencesHandler handler, final _NativeEvent event) {
handler.handlePreferences(new PreferencesEvent());
}
/**
* Installs a handler to show a custom Preferences window for your
* application.
* <p>
* Setting the {@link PreferencesHandler} to {@code null} reverts it to
* the default behavior
*
* @param preferencesHandler the handler to respond to the
* {@link PreferencesHandler#handlePreferences(PreferencesEvent)}
*
* @throws SecurityException if a security manager exists and it
* denies the
* {@code RuntimePermission("canProcessApplicationEvents")} permission
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#APP_PREFERENCES} action
* @since 9
*/
public void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
checkEventsProcessingPermission();
checkActionSupport(Action.APP_PREFERENCES);
peer.setPreferencesHandler(preferencesHandler);
}
/**
* Installs a handler to show a custom Preferences window for your
* application.
* <p>
* Setting the {@link PreferencesHandler} to {@code null} reverts it to
* the default behavior
*
* @param preferencesHandler the handler to respond to the
* {@link java.awt.desktop.PreferencesHandler#handlePreferences(PreferencesEvent) }
*/
default void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
}
/**
* Installs a handler to show a custom Preferences window for your
* application.
* <p>
* Setting the {@link PreferencesHandler} to {@code null} reverts it to
* the default behavior
*
* @param preferencesHandler the handler to respond to the
* {@link PreferencesHandler#handlePreferences(PreferencesEvent)}
*
* @throws SecurityException if a security manager exists and it
* denies the
* {@code RuntimePermission("canProcessApplicationEvents")} permission
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#APP_PREFERENCES} action
* @since 9
*/
public void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
checkEventsProcessingPermission();
checkActionSupport(Action.APP_PREFERENCES);
peer.setPreferencesHandler(preferencesHandler);
}
/**
* Installs a handler to show a custom Preferences window for your
* application.
* <p>
* Setting the {@link PreferencesHandler} to {@code null} reverts it to
* the default behavior
*
* @param preferencesHandler the handler to respond to the
* {@link java.awt.desktop.PreferencesHandler#handlePreferences(PreferencesEvent) }
*/
default void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
}
/**
* Installs a handler to create the Preferences menu item in your application's app menu.
*
* Setting the {@link PreferencesHandler} to {@code null} will remove the Preferences item from the app menu.
*
* @param preferencesHandler
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
eventHandler.preferencesDispatcher.setHandler(preferencesHandler);
}