save on close problem?

Hi I wish to save a file on close but it wont allow me to refrence any objects as it is static where I'm trying to set it up. My main class "TabDemo" has implenents actionListener but I can't also put implements WindowListener can I? Please can you tell me how I might get this WIndowListener to work? Here is a bit of the code:

The errors it gives me are like this: C:\TabDemo.java:326: non-static variable this cannot be referenced from a static context frame.addWindowListener(this); ^ C:\TabDemo.java:326: addWindowListener(java.awt.event.WindowListener) in java.awt.Window cannot be applied to (TabDemo) frame.addWindowListener(this); ^ 2 errors