001    /**
002     * Valentin Heinitz heinitz@freenet.de
003     * Interaction with the device. Learning input.
004     */
005    
006    import javax.microedition.lcdui.*;
007    import javax.microedition.midlet.MIDlet;
008    
009    
010    public class input extends MIDlet implements CommandListener {
011        private final static Command CMD_OK = new Command("OK", Command.OK, 1);
012        private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
013        private final static Command CMD_BACK = new Command("Zurück", Command.BACK, 1);
014        private final static Command cmd_cancel = new Command("Cancel", Command.CANCEL, 1);
015        private final static Command cmd_item = new Command("Item", Command.ITEM, 1);
016        private final static Command cmd_help = new Command("help", Command.HELP, 1);
017        private final static Command cmd_screen1 = new Command("Custom1", Command.SCREEN, 1);
018        private final static Command cmd_screen2 = new Command("Custom2", Command.SCREEN, 2);
019        private final static Command cmd_screen3 = new Command("Custom3", Command.SCREEN, 3);
020        private final static Command cmd_stop = new Command("Stop", Command.STOP, 1);
021        private Display display;
022        private Form mMainForm;
023        public input() {
024           mMainForm = new Form("---Input Test---");    
025           
026    /**
027    DOC
028    Adds a command to the Displayable. The implementation may choose, for example, 
029    to add the command to any of the available softbuttons or place it in a menu. 
030    If the added command is already in the screen (tested by comparing the object 
031    references), the method has no effect. If the Displayable is actually visible 
032    on the display, and this call affects the set of visible commands, the 
033    implementation should update the display as soon as it is feasible to do so.
034    
035    Die Klasse Form behandelt nur das Command "Zurück", andere Commands sind durch 
036    "Menu" aufrufbar
037    */
038           mMainForm.addCommand(CMD_EXIT);
039           mMainForm.addCommand(CMD_OK);
040           mMainForm.addCommand(CMD_BACK);
041           mMainForm.addCommand(cmd_cancel);
042           mMainForm.addCommand(cmd_item);
043           mMainForm.addCommand(cmd_help);
044           mMainForm.addCommand(cmd_screen1);
045           mMainForm.addCommand(cmd_screen2);
046           mMainForm.addCommand(cmd_screen3);       
047           mMainForm.addCommand(cmd_stop);
048           mMainForm.setCommandListener(this);
049           display = Display.getDisplay(this);
050        }
051    
052        protected void startApp() {
053           Display.getDisplay(this).setCurrent(mMainForm);
054        }
055    
056        protected void destroyApp(boolean unconditional) {
057        }
058    
059        protected void pauseApp() {
060        }
061    
062        public void commandAction(Command c, Displayable d) {
063            mMainForm.append(new StringItem(null, "CMND! Type:"
064               +c.getCommandType() +
065               "  Priority:"+c.getPriority()+" Label:"+c.getLabel()));
066               
067            if (c == CMD_EXIT) {
068                destroyApp(false);
069                notifyDestroyed();
070            }
071        }
072    }
073