There is a JFrame in which the JList and JTextField are located. The problem is that when you enter text into a JTextField, the JList loses focus and you cannot use the arrow keys to select items in it. How can I simultaneously accept arrow press events in JList and continue to edit text in JTextField?

    1 answer 1

    Events on a program scale can be heard as follows: getToolkit (). AddAWTEventListener; The idea is as follows: remove arrows from the common message queue and send them to the component using the processEvent (event) method; Here is what I added to the MyJList constructor:

    getToolkit().addAWTEventListener(new AWTEventListener() { final int KEY_DOWN=40; final int KEY_UP=38; @Override public void eventDispatched(AWTEvent event) { int keyCode=((KeyEvent)event).getKeyCode(); if (keyCode == KEY_DOWN|keyCode == KEY_UP) MyJList.this.processEvent(event); } },AWTEvent.KEY_EVENT_MASK);