Search code examples
javajava-melwuit

Override keypress method in lwuit


How to override keypressed method form in lwuit? if suppose user press numeric 1 from keypad how can I know that user has pressed 1? In canvas we just need to handle keypressed method. but in lwuit how to handle this method. and which listener I have to implements?


Solution

  • keypressed is method in interface so you always override that methos in class

    see this example

    if you dont khow exact key code then print key code in

    public void keyPressed(keyCode){
    System.out.println(keyCode);
    }
    

    run your program, press "1" and see output