01: /*
02: *
03: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
04: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License version
08: * 2 only, as published by the Free Software Foundation.
09: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * General Public License version 2 for more details (a copy is
14: * included at /legal/license.txt).
15: *
16: * You should have received a copy of the GNU General Public License
17: * version 2 along with this work; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
22: * Clara, CA 95054 or visit www.sun.com if you need additional
23: * information or have any questions.
24: */
25:
26: package com.sun.xlet;
27:
28: import java.awt.Container;
29: import java.awt.Frame;
30: import java.awt.FlowLayout;
31: import java.awt.event.WindowAdapter;
32: import java.awt.event.WindowEvent;
33: import java.util.Enumeration;
34:
35: public class ToplevelFrame extends Frame {
36:
37: // No real reason, some random values.
38: int width = 400;
39: int height = 300;
40:
41: public ToplevelFrame(String title, XletManager manager) {
42: super (title);
43: setSize(width, height);
44: addWindowListener(new XletFrameListener());
45:
46: addNotify(); // Do we need this for pp?
47: }
48:
49: class XletFrameListener extends WindowAdapter {
50: public void windowClosing(WindowEvent e) {
51: XletManager.exit();
52: }
53:
54: public void windowIconified(WindowEvent e) {
55: for (Enumeration enu = XletManager.activeContexts
56: .elements(); enu.hasMoreElements();) {
57: XletLifecycleHandler handler = (XletLifecycleHandler) enu
58: .nextElement();
59: handler.postPauseXlet();
60: }
61: }
62:
63: public void windowDeiconified(WindowEvent e) {
64: for (Enumeration enu = XletManager.activeContexts
65: .elements(); enu.hasMoreElements();) {
66: XletLifecycleHandler handler = (XletLifecycleHandler) enu
67: .nextElement();
68: handler.postStartXlet();
69: }
70: }
71: }
72:
73: // A request from XletContextImpl to create a new Container.
74: public Container getXletContainer() {
75: XletContainer c = new XletContainer();
76: if (getComponentCount() > 0) {
77: setLayout(new FlowLayout()); // If more than one xlet, FlowLayout
78: }
79: add(c);
80: validate();
81: setVisible(true);
82: c.setVisible(false);
83: return c;
84: }
85: }
|