开发者

Java GUI question

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 th开发者_运维问答at the program will interact with?


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!


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜