I have a console based (System.in and System.out based) Java standalone application. I am trying to convert it into an applet. But the problem is that there is no console in Java applet! In other words, when I write to system output it is not displayed to the user and similarly I am unable to get input from user in absence of a console.
I know that a console lookalike can be done using TextArea and KeyListener, but for that I would need two different components, one for input and one for output. I want the input and output to go into the same component. Any ideas?
But there is a standard console for Java applets 🙂
http://www.java.com/en/download/help/javaconsole.xml
http://download.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/console.html
Joking aside, there does seem to be some console code on this site: http://math.hws.edu/eck/cs124/javanotes2/source/index.html. Apparently you can just extend this class and it’ll give you a console in your applet. However, you may need to redirect System.out (standard output), System.err (error output) and System.in (input) into the console. That doesn’t seem to be implemented but could be blocked in applets by the SecurityManager.