AppletConsole

AppletConsole is a suite of Java classes written to enable Java programs to run, in a browser, in an command-line-like environment. The classes provide a 'console window', a button to start/terminate the application, and manage input and output for the application.

To use AppletConsole, the application must contain a class derived from AppletConsoleApp. The function main(), which is called when the application is run from the command-line, should instantiate the class and direct its input and output streams to those (in and out) declared in AppletConsoleApp, then call function run(). When run in a browser, streams are re-directed automatically and run() is invoked to execute the program.

This process is documented more fully in AppletConsoleApp.java. The example 'Hello World' program, which will be available below if you have Java-enabled browser, can be found in TestAppletConsoleApp.java. HTML statements for running a specified application are given below; the example assumes that, as on this website, the AppletConsole and application class files are in the same directory (here, ../class/).

To run TestAppletConsoleApp from a Java interpreter on your machine, download TestAppletConsoleApp.class and AppletConsoleApp.class into the same directory, where they can be invoked using a command like

java TestAppletConsole.class

where java is the name of your Java interpreter.

AppletConsole, AppletConsoleApp, TestAppletConsoleApp and associated classes are freeware issued under the GNU general public licence version 2. They are for educational purposes only and come with no warranty, implied or otherwise, as to their fitness for any purpose. The BIO disclaims all liability for damages, costs or injury resulting from the use of any information it publishes.

Your Browser seems to have no Java support. Please get a new browser or enable Java to see this applet!

Appletconsole takes the following parameters:
Name Type Default Description
appName AppletConsoleApp must be
defined
Name of the console app to be run, derived from AppletConsoleApp
rows int 25 Number of rows in the console
cols int 80 Number of columns in the console
bkColor #000000-#FFFFFF black RGB colour of console background
panelColor #000000-#FFFFFF grey RGB colour of applet background
fgColor #000000-#FFFFFF white RGB colour of console foreground
fontName string Courier Font used in console
fontStyle 0-3 0 Style 0=plain 1=bold 2=italic 3=bolditalic
fontSize 5-20 12 Font size in pixels
echo boolean false Whether echo is enabled in the console

For example, the above window is created with these HTML statements:

<APPLET CODEBASE="../class/" CODE="AppletConsole.class" WIDTH=590 HEIGHT=430>
  <PARAM NAME=appName VALUE="TestAppletConsoleApp">
  <PARAM NAME=rows VALUE="25">
  <PARAM NAME=cols VALUE="80">
  <PARAM NAME=bkColor VALUE="#000000">
  <PARAM NAME=panelColor VALUE="#C0C0C0">
  <PARAM NAME=fgColor VALUE="#FFFFFF">
  <PARAM NAME=fontName VALUE="Courier">
  <PARAM NAME=fontStyle VALUE="0">
  <PARAM NAME=fontSize VALUE="12">
  <PARAM NAME=echo VALUE="false">

  <!-- make sure non-java-capable browser get a message: -->
  <B>
  Your Browser seems to have no <A HREF="http://java.sun.com/">Java</A>
  support. Please get a new browser or enable Java to see this applet!
  </B>
</APPLET>

The British Informatics Olympiad