0

I want to listen keyboard event over all control in my jframe to show new window, so far this is my code :

KeyboardFocusManager.getCurrentKeyboardFocusManager()
                .addKeyEventDispatcher(new KeyEventDispatcher() {
                    @Override
                    public boolean dispatchKeyEvent(KeyEvent evt) {
                      int key = evt.getKeyCode();
                         if (evt.isControlDown() && key == KeyEvent.VK_F1) {

                           JManualTransction FrmManual = new JManualTransaksi();  
                           FrmManual.SetVisible(true);  

                          }
                        return false;
                    }
            });

But the problem is the FrmManual window is always show twice when i press CTRL + F1 May somebody can tell me why?

thanks ....

NYassuki
  • 23
  • 3
  • You're likely getting a key pressed AND key released event. This isn't actually the best choice, in fact you might find using a key binding is generally easier. See [How to Use Key Bindings](http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html) for more details – MadProgrammer Nov 08 '15 at 10:02
  • @MadProgrammer : Yes I get pressed and released even so i add KeyEvent.KEY_PRESSED, thanks – NYassuki Nov 08 '15 at 10:25

0 Answers0