import java.applet.*; import java.awt.*; import java.awt.event.*; import com.genuts.gameui.*; public class MouseTimeApplet extends Applet implements KeyListener { private PlayField playfield; private TimeWrapper timeSprite = null; public void init() { setLayout(null); // Creates the playfield playfield = new PlayField(320, 240); playfield.setBackground(Color.white); // Creates the time label SpriteLabel label = new SpriteLabel(""); label.setFont(new Font("SansSerif", Font.BOLD, 24)); label.setColor(Color.gray); timeSprite = new TimeWrapper(label); Sprite sprite = new MovingWrapper(new MouseWrapper(timeSprite), 2, 2); playfield.addSprite(sprite); // Displays the playfield add(playfield); // Adds this applet as KeyListener to the playfield playfield.addKeyListener(this); } public void start() { // Activate the playfield playfield.setPause(false); // Request the focus for the playfield playfield.requestFocus(); } public void stop() { playfield.stop(); } ////////////////////////////////////////////// ///// KeyListener ////////////////////////// ////////////////////////////////////////////// public void keyTyped(KeyEvent e) { if (timeSprite.getDisplay() != TimeWrapper.DISPLAY_DATE) { timeSprite.setDisplay(TimeWrapper.DISPLAY_DATE); } else { timeSprite.setDisplay(TimeWrapper.DISPLAY_24HOURS); } } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { } }