HelloKeyInput and funny JOptionPane behaviour

So, I added the following bits of code to HelloKeyInput…



to simpleInitGame(), I added…



        KeyBindingManager.getKeyBindingManager().set(

            "JOP",

            KeyInput.KEY_I);



and to simpleUpdate I added…



        if (KeyBindingManager.getKeyBindingManager().isValidCommand("JOP", false))  {

            javax.swing.JOptionPane.showConfirmDialog(null, "message4");

        }





So when I run the app, when I press 'i' the first time my optionPane comes up.



I answer the optionPane.



Then I press 'i' again and nothing happens.



Then I press 'i' again and the optionPane comes up again.



I don't understand why.  :frowning:



Any help?

if you press i, the option pane pops up, then you release i, but jME doesn't catch the release event.

When you close the option pane, jme thinks i is still pressed.



What you can do is, clear the I key after the pane is closed:


        if (KeyBindingManager.getKeyBindingManager().isValidCommand("JOP", false))  {
            System.out.println("valid");
            javax.swing.JOptionPane.showConfirmDialog(null, "message4");
            KeyInput.get().clearKey(KeyInput.KEY_I);
        }


Thanks, I'll give it a try.  8)

…and it works!



Thanks.