2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
* You should have received a copy of the GNU General Public License
11
* along with this program; if not, write to the Free Software
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
package games.strategy.common.ui;
17
import com.apple.eawt.Application;
18
import com.apple.eawt.ApplicationAdapter;
19
import com.apple.eawt.ApplicationEvent;
23
* Utility class to wrap Mac OS X-specific shutdown handler.<p>
25
* Based on TripleA code.<p>
27
* Needs AppleJavaExtensions.jar to compile on non-Mac platform.
29
* @author Lane Schwartz
30
* @see http://developer.apple.com/samplecode/AppleJavaExtensions/index.html
32
public class MacWrapper
34
private static MainGameFrame s_shutdownFrame;
35
private static Application application = new Application();
39
application.addApplicationListener(
40
new ApplicationAdapter() {
41
public void handleQuit(ApplicationEvent event)
43
if(s_shutdownFrame != null)
44
s_shutdownFrame.shutdown();
50
//keep this in its own class, otherwise we get a no class def error when
51
//we try to load the game and the stubs arent in the classpath
52
//i think the java validator triggers this
53
public static void registerMacShutdownHandler(final MainGameFrame frame)
55
s_shutdownFrame = frame;
59
public static void unregisterShutdownHandler()
61
s_shutdownFrame = null;