Reputation: 48
I am trying to allow for a JTextArea to have focus but if the user enters keyboard input and control is not pressed then to forward that key event on to the command JTextField.
I tried to simply append the key char to the text in the JTextField but that results in unknown characters when pressing anything except letters, symbols, or numbers.
newField.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if(!e.isControlDown()) {
Console.consoleWindow.appendTextToCMD(e.getKeyChar());
}
}
});
Upvotes: 0
Views: 254
Reputation: 35011
You need to use processEvent on your other JComponent. Also, you need to create a new AWTEvent - copy all fields but with the source being the new JComponent
Upvotes: 1