Apple Java Extensions

com.apple.eawt
Interface ApplicationListener

All Superinterfaces:
java.util.EventListener
All Known Implementing Classes:
ApplicationAdapter

public interface ApplicationListener
extends java.util.EventListener

The listener interface for receiving ApplicationEvents. Classes needing to process Application Events implement this interface. Multiple listeners are allowed for each event. When an event is fired off, an ApplicationEvent is sent to each listener in turn until one of the them sets isHandled to true. Before being able to receive ApplicationEvents, the listener must register with the Application object's addListener method. A default implementation of this interface is provided in the ApplicationAdapter class.


Method Summary
 void handleAbout(ApplicationEvent event)
          Called when the user selects the About item in the application menu.
 void handleOpenApplication(ApplicationEvent event)
          Called when the application receives an Open Application event from the Finder or another application.
 void handleOpenFile(ApplicationEvent event)
          Called when the application receives an Open Document event from the Finder or another application.
 void handlePreferences(ApplicationEvent event)
          Called when the Preference item in the application menu is selected.
 void handlePrintFile(ApplicationEvent event)
          Called when the application is sent a request to print a particular file or files.
 void handleQuit(ApplicationEvent event)
          Called when the application is sent the Quit event.
 void handleReOpenApplication(ApplicationEvent event)
          Called when the application receives a Reopen Application event from the Finder or another application.
 

Method Detail

handleAbout

void handleAbout(ApplicationEvent event)
Called when the user selects the About item in the application menu. If event is not handled, by setting isHandled(true), a default About window consisting of the application's name and icon is displayed. To display a custom About window, designate the event as being handled and display the appropriate About window.

Parameters:
event - an ApplicationEvent initiated by the user choosing About in the application menu

handleOpenApplication

void handleOpenApplication(ApplicationEvent event)
Called when the application receives an Open Application event from the Finder or another application. Usually this will come from the Finder when a user double-clicks your application icon. If there is any special code that you want to run when you user launches your application from the Finder or by sending an Open Application event from another application, include that code as part of this handler. The Open Application event is sent after AWT has been loaded.

Parameters:
event - the Open Application event

handleOpenFile

void handleOpenFile(ApplicationEvent event)
Called when the application receives an Open Document event from the Finder or another application. This event is generated when a user double-clicks a document in the Finder. If the document is registered as belonging to your application, this event is sent to your application. Documents are bound to a particular application based primarily on their suffix. In the Finder, a user selects a document and then from the File Menu chooses Get Info. The Info window allows users to bind a document to a particular application. These events are sent only if the bound application has file types listed in the Info.plist entries Document Types or CFBundleDocumentTypes. The ApplicationEvent sent to this handler holds a reference to the file being opened.

Parameters:
event - an Open Document event with reference to the file to be opened

handlePreferences

void handlePreferences(ApplicationEvent event)
Called when the Preference item in the application menu is selected. Native Mac OS X applications make their Preferences window available through the application menu. Java applications are automatically given an application menu in Mac OS X. By default, the Preferences item is disabled in that menu. If you are deploying an application on Mac OS X, you should enable the preferences item with setEnabledPreferencesMenu(true) in the Application object and then display your Preferences window in this handler.

Parameters:
event - triggered when the user selects Preferences from the application menu

handlePrintFile

void handlePrintFile(ApplicationEvent event)
Called when the application is sent a request to print a particular file or files. You can allow other applications to print files with your application by implementing this handler. If another application sends a Print Event along with the name of a file that your application knows how to process, you can use this handler to determine what to do with that request. You might open your entire application, or just invoke your printing classes. These events are sent only if the bound application has file types listed in the Info.plist entries Document Types or CFBundleDocumentTypes. The ApplicationEvent sent to this handler holds a reference to the file being opened.

Parameters:
event - a Print Document event with a reference to the file(s) to be printed

handleQuit

void handleQuit(ApplicationEvent event)
Called when the application is sent the Quit event. This event is generated when the user selects Quit from the application menu, when the user types Command-Q, or when the user control clicks on your application icon in the Dock and chooses Quit. You can either accept or reject the request to quit. You might want to reject the request to quit if the user has unsaved work. Reject the request, move into your code to save changes, then quit your application. To accept the request to quit, and terminate the application, set isHandled(true) for the event. To reject the quit, set isHandled(false).

Parameters:
event - a Quit Application event

handleReOpenApplication

void handleReOpenApplication(ApplicationEvent event)
Called when the application receives a Reopen Application event from the Finder or another application. Usually this will come when a user clicks on your application icon in the Dock. If there is any special code that needs to run when your user clicks on your application icon in the Dock or when a Reopen Application event is sent from another application, include that code as part of this handler.

Parameters:
event - the Reopen Application event

Apple Java Extensions

To file bugs or suggest feature enhancements for the Java implementation in Mac OS X, visit the Apple Developer Connection Bug Reporter website. File bugs under the Java (new bugs) component, version X.

Additional documentation for Java development on Mac OS X is available online at the Java Developer Documentation website.

© Apple Computer, Inc. March 2008