LandmarkNameBox.java

/**
 * Copyright (c) 2012 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.example.compass.views;

import com.nokia.example.compass.CompassMidlet;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;

public class LandmarkNameBox extends TextBox implements CommandListener{

    Command backCmd;
    AddLandmarkView view;

    public LandmarkNameBox(AddLandmarkView view) {
        super("Name of the location", "", 120, TextField.ANY);
        backCmd = new Command("Done",  Command.BACK, 1);
        this.addCommand(backCmd);
        this.setCommandListener(this);
        this.view = view;
    }
    public void commandAction(Command cmnd, Displayable disp) {
        if(cmnd == backCmd) {
            view.setLandmarkName(this.getString());
            //CompassMidlet.getInstance().getCompassView().skipNextKey();
            CompassMidlet.getInstance().showCompassView();
        }
    }
}