FileDocCategorySizeDatePackage
EventEx4.javaAPI DocExample1625Sat Jan 05 11:47:12 GMT 2002None

EventEx3

public class EventEx3 extends MIDlet

Fields Summary
Display
display
Command
exit
Constructors Summary
public EventEx3()

      display = Display.getDisplay(this);
   
Methods Summary
public voiddestroyApp(boolean unconditional)

   
public voidpauseApp()

      System.out.println("App paused.");
   
public voidstartApp()

      display = Display.getDisplay(this);

      Canvas canvas = new Canvas() { // anonymous class     
         public void paint(Graphics g) {
         }

         protected void keyPressed(int keyCode) {
            if (keyCode > 0) {
               System.out.println("keyPressed " +((char)keyCode));
            } else {
               System.out.println("keyPressed action " +getGameAction(keyCode));
            }                  
         }

         protected void keyReleased(int keyCode) {
            if (keyCode > 0) {
               System.out.println("keyReleased " +((char)keyCode));
            } else {
               System.out.println("keyReleased action " +getGameAction(keyCode));
            } 
         }
      }; // end of anonymous class

      exit = new Command("Exit", Command.STOP, 1);
      canvas.addCommand(exit);
      canvas.setCommandListener(new CommandListener() {
         public void commandAction(Command c, Displayable d) {
            if(c == exit) {
               notifyDestroyed();
            } else {
               System.out.println("Saw the command: "+c);
            }
         }
      });
      display.setCurrent(canvas);