Hello
I'm writing simple j2me calculator. using GameCanvas class as a basis of my interface. I need to handle both numpad key events and game-relaited events (such as UP, DOWN, FIRE, etc) for moving my cursor. The problem is that neither emulator, nor my Sony Ericsson doesn't receives some numpad and game-relaited events. For example, I get SOFT1, SEND, 2, 4, ASTERISK key pressed events, but don't receive 1, 3, LEFT, RIGH, UP, DOWN, FIRE events.class CalculatorCanvas extends GameCanvas
{
    public CalculatorCanvas() throws java.io.IOException
    {
        super(true);
        setFullScreenMode(true);
        cursor = new Sprite(Image.createImage("/cursor.png"));
    }
    public void paint(Graphics g)
    {
        g.setColor(0);
        g.fillRect(0, 0, getWidth(), getHeight());
        cursor.paint(g);
    }
    protected void keyPressed(int keyCode)
    {
        System.out.println("keyPressed: " + get开发者_JAVA技巧KeyName(key));
        if (keyCode == getKeyCode(RIGHT))
            cursor.move(STEP, 0);
        if (key == getKeyCode(LEFT))
            cursor.move(-STEP, 0);
            /*...*/
        repaint();
    }
    private final int STEP = 3;
    private Sprite cursor;
}  
How can I receive all this events?
Thanks in advancePS I've found that Canvas (base class for GameCanvas) reseives all this events, but I have to use GameCanvas
check javadoc for GameCanvas constructor. You should call it with "false" !
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论