Question: In a Java application on a Mac, you can click the top bar and select Quit to exit the program. How can I add a listener to my JFrame to listen to this?

I did a search on this and found ApplicationListener, however Eclipse puts a "cross out" in this and seems to think its deprecated or something.

Specifically, I found to use com.apple.eawt.ApplicationListener, but how do I do this? Do I need to download this com.apple.eawt package? I can't seem to find it.

Answer: 
You need to register an ApplicationListener:

There is a sample application available from Apple:

<http://developer.apple.com/library/mac/#samplecode/OSXAdapter/Introduction/Intro.html>
You can catch when cross out button clicked like this 
```
frame.addWindowListener(new ExitListener());
```

And then you can overwrite it like this 
```
 public class ExitListener extends WindowAdapter{
        public void windowClosing(WindowEvent e){
            //some codes
        }
    }

```