HelloWorldMidlet.java

/*
 * Copyright © 2011 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners.
 * See LICENSE.TXT for license information.
 */
package com.nokia.midp.examples.svg;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * Simple midlet that displays a static SVG file.
 */
public class HelloWorldMidlet extends MIDlet implements CommandListener {

    /**
     * Constructor.
     */
    public HelloWorldMidlet() {

        // *** create the SVG canvas
        svgCanvas = new SvgCanvas1(false);
        svgCanvas.setCommandListener(this);

        // *** grab a reference to the display
        display = Display.getDisplay(this);
        display.setCurrent(svgCanvas);

        // *** set up the midlet menu
        int hotKey = 0;

        cmExit = new Command("Exit", Command.SCREEN, hotKey++);
        svgCanvas.addCommand(cmExit);
    }

    /**
     * Required midlet method.
     */
    public void startApp() {
    }

    /**
     * Required midlet method.
     */
    public void pauseApp() {
    }

    /**
     * Required midlet method.
     */
    public void destroyApp(boolean unconditional) {
    }

    /**
     * Handle the various menu actions.
     */
    public void commandAction(Command c, Displayable s) {
        if (c == cmExit) {
            destroyApp(false);
            notifyDestroyed();
        }
    }
    /*
     * Private members
     */
    private Display display;
    private SvgCanvas1 svgCanvas;
    private Command cmExit;
}