00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package org.classroomgaming.cgp;
00023
00024 import java.awt.*;
00025 import java.net.MalformedURLException;
00026 import java.net.URL;
00027 import java.util.logging.Level;
00028 import java.util.logging.Logger;
00029 import javax.swing.*;
00030
00036 public class CGPApplet extends JApplet implements Configurator, ImageLoader {
00037
00038 public static final long serialVersionUID = 1L;
00039 private GameViewer view;
00040
00041
00042
00043 private Font font = new Font("serif", Font.ITALIC + Font.BOLD, 36);
00044 private boolean enabled = true;
00045
00046 public void init() {
00047
00048
00049
00050
00051
00052
00053 String laf = UIManager.getSystemLookAndFeelClassName();
00054 try {
00055 UIManager.setLookAndFeel(laf);
00056 } catch (UnsupportedLookAndFeelException exc) {
00057 System.err.println("Warning: UnsupportedLookAndFeel: " + laf);
00058 } catch (Exception exc) {
00059 System.err.println("Error loading " + laf + ": " + exc);
00060 }
00061 getContentPane().setLayout(null);
00062
00063
00064 view = new GameViewer(this);
00065 this.add(view);
00066 view.setEnabled(true);
00067 view.setVisible(true);
00068 view.start();
00069 requestFocus();
00070
00071
00072 }
00073
00074 public ImageLoader getImageLoader() {
00075 return this;
00076 }
00077
00078 public Image loadImage(String name)
00079 {
00080 try {
00081 java.net.URL imageURL;
00082 imageURL = new java.net.URL(getDocumentBase(), name);
00083 return Toolkit.getDefaultToolkit().getImage(imageURL);
00084 } catch (MalformedURLException ex) {
00085
00086 return null;
00087 }
00088
00089 }
00090
00091 }