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?
Asked
Active
Viewed 157 times
1
-
1Does http://stackoverflow.com/questions/342990/create-java-console-inside-the-panel answer your question? – Jerome May 25 '11 at 01:29
2 Answers
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!

Hovercraft Full Of Eels
- 283,665
- 25
- 256
- 373
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.

Ants
- 1,338
- 16
- 27