package com.javaonthebrain.choco; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** * @author Karl H. */ public class ChocoBan extends MIDlet { private boolean midletPaused = false; private ChocoCanvas m_canvas; /** * The ChocoBan constructor. */ public ChocoBan() { } /** * Initilizes the application. * It is called only once when the MIDlet is started. The method is called before the startMIDlet method. */ private void initialize() { // write pre-initialize user code here m_canvas = new ChocoCanvas(this); m_canvas.initialize(); // write post-initialize user code here } /** * Performs an action assigned to the Mobile Device - MIDlet Started point. */ public void startMIDlet() { m_canvas.startUp(); Display.getDisplay(this).setCurrent(m_canvas); } /** * Performs an action assigned to the Mobile Device - MIDlet Resumed point. */ public void resumeMIDlet() { m_canvas.startUp(); } /** * Exits MIDlet. */ public void exitMIDlet() { m_canvas.shutDown(); destroyApp(true); notifyDestroyed(); } /** * Called when MIDlet is started. * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet. */ public void startApp() { if (midletPaused) { resumeMIDlet (); } else { initialize (); startMIDlet (); } midletPaused = false; } /** * Called when MIDlet is paused. */ public void pauseApp() { midletPaused = true; m_canvas.shutDown(); } /** * Called to signal the MIDlet to terminate. * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released. */ public void destroyApp(boolean unconditional) { } }