KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Component source = kfm.getFocusOwner(); if (source == null) source = tk.getTop(); KeyEvent me = new KeyEvent(source, id, time, modifiers, keyCode,
KeyEvent me = new KeyEvent(tk.getTop(), id, time, modifiers, keyCode,
    private void postEvent(int id, long time, int modifiers, int keyCode,            char keyChar) {        JNodeToolkit tk = (JNodeToolkit) Toolkit.getDefaultToolkit();        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();        Component source = kfm.getFocusOwner(); // TODO get the global focus owner        if (source == null)            source = tk.getTop();        KeyEvent me = new KeyEvent(source, id, time, modifiers, keyCode,                keyChar);        eventQueue.postEvent(me);    }