Create Java Command Console in JPanel

落花浮王杯 提交于 2019-12-31 02:08:49

问题


I want to create a "Command Console" similar to the Windows Command Prompt, with command history, etc which is in a JPanel so that it can be added to a JFrame.

What I want to do is present the user with the prompt to allow them to execute commands.

What I have in mind is similar to the BeanShell Console, however I haven't be able to find the source code for the console.


回答1:


To include BeanShell into your application, add the .jar-files from the BeanShell download page to your Java project and see the BeanShell doc section "Calling Beanshell from your Application" for examples how to call Beanshell with direct calls or by evaluating the commands from your shell.

See also the Quickstart Guide for other ways and examples how to use BeanShell.




回答2:


BeanShell provides JConsole, a command line console that can be used in your own application WITHOUT the overhead of the rest of the BeanShell functionality. See my example of using it here: Create a "Command" Console

The BeanShell source is available via SVN from svn co http://ikayzo.org/svn/beanshell

For more info on JConsole see http://www.beanshell.org/manual/jconsole.html



来源:https://stackoverflow.com/questions/970850/create-java-command-console-in-jpanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!