Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextArea used as a modem terminal

 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.

Works like a charm.

Regards,
Aaron R>
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Would be greatful in seeing your code for displaying the contents of the serial port..
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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.
 
The only thing that kept the leeches off of me was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic