1

So in my project, I have an interactive program that requires the user to enter values to get a response in the console. How do I make it so that the console appears in a textbox in the GUI while the user enters responses that the program will interact with?

1

2 Answers 2

1

Some suggestions:

  • First of all, make sure that your program is a true OOPS program with decent classes and minimal static methods and members.
  • Next make sure that your user interface and program logic code are in separate classes.
  • Note that you'll want to redesign your program as you really don't want to try to run a console-like program in a GUI as you requested above since it defeats the purpose of doing event-driven GUI programming. Rather create a GUI that accepts data as most GUI's would, with text fields buttons and such, where the user can choose to interact with whatever component is available for him to interact with, rather than the forced linear interaction of a console program.
  • Lastly read the Swing tutorials to learn how to create Swing GUIs. That's all there is to it!
Sign up to request clarification or add additional context in comments.

Comments

1

You might want to check out this link (thanks Google)

http://www.devdaily.com/java/java-exec-processbuilder-process-1

But essentially you need to:

  • use Process p = Runtime.getRuntime().exec("") to run a command then,
  • use p.getInputStream() to get the output and you can put this where you like.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.