• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with outputting batch file launched by Jbutton into TextArea

 
Andrew Novak
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code set up that is supposedly running the batch file.What I need help with is outputting the batch file to a JTextArea in my GUI. I'm not really sure how to direct my code to my JTextArea called "textareA". I basically want the textArea to be a console instead of command prompt. I know I'm really close, but I'm not sure what's wrong with my code. Any Suggestions?

 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross posted: http://stackoverflow.com/questions/30655309/outputting-batch-file-to-jtextarea

You could have responded to this posting when you got an answer, so people don't waste time reading the question and potentially answering a question that has already been answered.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RC is right.
Where are you waiting 10″? That is mentioned on the SO thread, too. Is that the right time for the process to complete? If you are doing it from the event dispatch thread, that will cause your GUI to hang for 10″.
You will doubtless by now have seen what an awful method read() is. I agree with whoever told you on SO to use a different technique to empty those Streams. Why are you only emptying the input stream and not the error stream? Why are you not using waitFor()? I know things have changed slightly with the introduction of the ProcessBuilder class, but you should never go anywhere near Runtime#exec until you are familiar with the classic article by Michael Daconta.

And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!