01: /*
02: * @(#)DemoXlet.java 1.5 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26: package basis;
27:
28: import java.awt.*;
29: import java.util.ArrayList;
30: import javax.microedition.xlet.*;
31:
32: public class DemoXlet implements Xlet {
33: protected static ArrayList demos = new ArrayList();
34: private XletContext context;
35: private Container container;
36: private Builder builder;
37:
38: static {
39: demos.add("basis.demos.GraphicsDemo");
40: demos.add("basis.demos.FontDemo");
41: demos.add("basis.demos.EventDemo");
42: demos.add("basis.demos.MiscDemo");
43: demos.add("basis.demos.GameDemo");
44: }
45:
46: public static void main(String[] args) throws Exception {
47: System.out.println("");
48: System.out.println("USAGE:");
49: System.out
50: .println(" cvm com.sun.xlet.XletRunner -name basis.DemoXlet -path .");
51: System.out.println("");
52: System.exit(1);
53: }
54:
55: public DemoXlet() {
56: builder = new Builder(demos);
57: }
58:
59: public void initXlet(XletContext context) {
60: System.out.println("initXlet");
61: this .context = context;
62: try {
63: container = context.getContainer();
64: builder.build(container);
65: Dimension d = container.getSize();
66: d.width = d.width > 240 ? d.width : 240;
67: d.height = d.height > 320 ? d.height : 320;
68: container.setSize(d.width, d.height);
69: container.validate();
70: } catch (Exception e) {
71: e.printStackTrace();
72: }
73: }
74:
75: public void startXlet() {
76: System.out.println("startXlet");
77: container.setVisible(true);
78: }
79:
80: public void pauseXlet() {
81: System.out.println("pauseXlet");
82: }
83:
84: public void destroyXlet(boolean unconditional) {
85: System.out.println("destroyXlet");
86: }
87: }
|