views:

126

answers:

0

Hello,

I show() a JPopupMenu based on what the user types in a JTextField, however, when that happens the user typing on the keyboard will no longer write into the text field, unless with the mouse clicks again on the field, thus closing the popup menu.

I want, like in Eclipse and NetBeans code completion feature, that the user may still type in the field even if the popup menu comes out, although typing might close the popup menu (and in the IDEs that actually generates a new popupmenu with different content).

How can I achieve that? I thought it had to do with Focus. Setting the popup notfocusable is a solution, another is to setVisible the popup, rather than show()ing it.

However this leads to: 1. Having to specify the x,y coordinates for the popup, in case of setVisible. 2. the field doesn't receive focus from the keyboard at all. In the IDE the first item of the popup menu is already selected so hitting enter submits it, while down button scrolls the list. However typing from the keyboard resuming typing in the field (text area) and generates a new popup.

How can I achieve the above?