Hi,
I am trying the following code to trap joystick events say, DISPLAY.KEY_LEFT while using a panel in IApplication.
I could trap all the other key events except for joystick key events? I am also successfull in trapping the joystick key events using processEvent() in the case of a canvas. Can any one suggest a different approach for trapping joystick events for a Panel?
import com.nttdocomo.ui.*;
import com.nttdocomo.io.*;
public class Sample2_11 extends IApplication{
public void start(){
IappPanel mypanel = new IappPanel();
Display.setCurrent(mypanel);
}
}
class IappPanel extends Panel implements KeyListener{
Label label;
Label label2;
IappPanel(){
setTitle("KeyListener Test");
label = new Label("Key:");
label2 = new Label("");
setLayoutManager(null);
add(label);
add(label2);
label.setLocation(0,20);
label2.setLocation(40,20);
setKeyListener(this);
}
public void keyPressed(Panel p,int key){
System.out.println("Key pressed ....");
if(key == Display.KEY_LEFT)
label2.setText("KEYLEFT");
else
label2.setText("Key pressed ....");
}
public void keyReleased(Panel p,int key){
}
}
////////////////////////////////////
thanks very much!
Ravi
Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more.
Received on Thu Feb 26 08:38:33 2004