Java/Swing: Problem with key listener?

So I added a KeyListener to the JTextField and it's working OK You should NOT be using a KeyListener for this. You should be adding a an ActionListener to the textfield In general you should not use KeyListeners you should be using Key Bindings.

So I added a KeyListener to the JTextField and it's working OK. You should NOT be using a KeyListener for this. You should be adding a an ActionListener to the textfield.In general you should not use KeyListeners you should be using Key Bindings.

Thanks, that worked. I'm new to Java, I didn't know about key bindings. I forgot to mention I had tried setting an accelerator from NetBeans' action dialog, but it wasn't working, so I tried the key listener.

Thanks again! – Mike May 19 '10 at 5:16.

So I added a KeyListener to the JTextField and it's working OK. The user opens can open the dialog by pressing Enter when a "Search" button on the dialog's parent frame is focused. The dialog is displayed and the JTextField gets the keyReleased event (from the Enter key that displayed it), so it shows up and closes.

If the user holds Enter down, then the JTextField receives the keyPressed, keyTyped and keyReleased events. How can I fix without resorting to ugly workarounds? Platform is Windows 7 x64, btw.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions