Spectrum application

This is a simple example of a stand-alone windowed application; when started, it displays a 'frame window' in the middle of the desktop and fills it with a spectrum of colors. This example assumes that Java 1.1 is available.

Here's the source, as a plain ASCII file.

To run the program, create or copy the 'Spectrum.nrx' file (note the first letter is a capital letter), and then enter the commands:

  java Spectrum

  java Spectrum

If you are using OS/2 or Windows, or other systems where a NetRexxC command is provided, you can use the single command

  netrexxc -run Spectrum

to do this. This command would:
  1. Call the NetRexx translator to translate the program from NetRexx to Java
  2. Call the Java compiler (javac) to compile the program into a class file (this assumes you've installed the Java 1.1 or later toolkit)
  3. Call the Java interpreter (java) to interpret the class file, which should then display the spectrum. You can try resizing the window to watch it redrawing the spectrum, or close it in the same way as other desktop applications.

If you would like to try it without compiling it first, here's the class file. Download this by clicking on the link, then change to the directory where you placed the class file and then run

  java Spectrum

Note that you must use the capital letter in this case, as the java command is case-sensitive; also, the Java runtime (e.g., from the Java 1.1.2 or later Development Kit) must be installed on your computer for this to run.

For a more sophisticated application, with a menu bar, multiple threads, and so on, see the Pinger example.

[ IBM | Help | Legal | Privacy ]