Thanks for the replies. I tried keys bindings but it didn't work. From my research the binding only works if the window is active. Since it seems I cannot bind a key to a JDialog, I had to bind it to the parent. Since the parent is not active, the JDialog is, the key press is not seen. Here is how I had to implement the binding ('dialog' is my JDialog component):
The println never happens.