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.
Any ideas?
Thanks, Aaron R>
Aaron Roberts
Ranch Hand
Joined: Sep 10, 2002
Posts: 174
posted
0
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.
Originally posted by FERNANDO HOOD: Would be greatful in seeing your code for displaying the contents of the serial port..
Please don't drudge up posts that are nearly 4 years old. I am closing this thread as the OP solved his own problem anyway so there is no need for any more discussion.