Close JPopupMenu on Keystroke

Hey Guys. Im creating tool to autocomplete Text for the Processing IDE. The following class Is the popup-menu that pops up to present the different fill-in possibilities:

class Entry extends JPopupMenu implements KeyListener{

    private JEditTextArea parent;
    public Entry(String word, JEditTextArea _parent) {
        parent = _parent;
    public void show(int x, int y) {, x, y);
    public void keyPressed(KeyEvent key) {
    public void keyReleased(KeyEvent key) {}

    public void keyTyped(KeyEvent key) {}

The class gets called by the Autocomplete class, which passes the Sting of the typed word and the editor.getTextArea() as an argument.

The problem is, that as soon as the popup opens it blocks the further input of new characters and you have to manually close it by pressing ESC. I tried to make it a KeyListener and make it close on a keystroke, but had no success so far. Is there a way I can make it close on an incoming keystroke?

1 Like

Question has been answered here: