This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am trying to create a pseudo terminal program, which prints characters from the serial port to a JTextArea. When the user types in the JTextArea, I want the text sent out the serial port.
I can do the first part with no problem. I'm stumped on the second. A normal modem terminal has a setting for local echo. If its on, then each key you type shows up in the window and gets sent out. If its off, then the character is simply sent out the serial port.
How can emulate this behavior? I know I can register a KeyListener, but that won't help if the key already shows up in the text area and its not supposed to.
Thanks, Aaron R>
Joined: Sep 10, 2002
Figured it out!
Register a KeyListener with the JTextPanel. In the keyTyped() method of the listener, do a consume on the key event if you don't want it to show up in the textpanel.