• Post Reply 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Input and Output Streams with JTextArea

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I was wondering if there was a way to 'connect' a Input and output stream to a jtextarea? What I am really trying to do is have a JTextArea behave like the standard in and standard out. Is this possible? If so how?

What kind of Input/Output Stream classes should I use? Know of any tutorials / examples of doing something like this?

Thanks,
Matt
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by matt eggbeers:
[QB]I was wondering if there was a way to 'connect' a Input and output stream to a jtextarea?



JTextArea (or any JTextComponent) has read() and write() methods.

What I am really trying to do is have a JTextArea behave like the standard in and standard out.



read() calls for a Reader, not an InputStream, but you can convert with InputStreamReader.

write() calls for a Writer, not an OutputStream, but you can convert with OutputStreamWriter.
 
matt eggbeers
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the response, what about when using the Text Object in SWT? Is there a way to do it then? The Text object does not have read or write methods.

Thanks,
Matt
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This blog post describes redirecting OutputStreams (specifically System.out) to a SWT Text component.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and another

http://codeguru.earthweb.com/java/articles/382.shtml
 
I brought this back from the farm where they grow the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic