Search code examples
swingkeyboardjframeawtjtextfield

How to input text from a swing on screen keyboard to another swing JFrame


2 frames

I have a swing on screen keyboard that can be used to send key presses to the other JFrame but it is not focusing on the JTextField.

Should I put jtextfield.requestfocus in every key so it should work?

Note:

The Input JFrame calls the keyboard Swing and passes the JTextField instance for focus request


Solution

  • When you create your keyboard frame you can use:

    frame.setFocusableWindowState(false);
    

    This should prevent the window from receiving focus to focus will remain on the other window.