/* * Copyright © 2013 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.satsa; import com.nokia.mid.ui.IconCommand; import javax.microedition.lcdui.*; // Displays a form to enter new messages class NewScreen extends Form implements CommandListener { private final SATSAMIDlet midlet; private final Command commandBack = new Command("Back", Command.BACK, 1); private final Command commandSave = new Command("Save", Command.ITEM, 1); /**Creates a new IconCommand with the given label, type, priority and system icon id. */ private final IconCommand commandSaveAction1 = new IconCommand("OK", Command.OK, 1, IconCommand.OK); TextField messageField; TextField passwordField; NewScreen(SATSAMIDlet midlet) { super(null); this.midlet = midlet; } public void commandAction(Command c, Displayable d) { if (c == commandBack) { midlet.showMessageList(); } else if (c == commandSave || c == commandSaveAction1) { midlet.addNewMessage(messageField.getString(), passwordField.getString()); } } void createForm() { deleteAll(); setTitle("Add new message "); messageField = new TextField("Message", "", 80, TextField.ANY); // Notice that the max length is 16 as indicated for the AES key passwordField = new TextField("Password", "", 16, TextField.PASSWORD); append(messageField); append(passwordField); addCommand(commandBack); addCommand(commandSave); addCommand(commandSaveAction1); setCommandListener(this); } }