IBM

The NetRexx Tablet applet

This is an example of a Java navigation applet, which has been written in NetRexx; when in use, it looks something like this:
/card-index\/tabs\
These tabs can be used to give a 'horizontally organized' feel to a web site.

Notes:

  1. When live, the tabs react to the mouse pointer moving over them by turning the text blue (indicating that they are clickable).
  2. The text for each tab, and the URL that each tab selects, is set by parameters to the applet (see below); each tab is sized to fit the text.
  3. A further parameter chooses which tab appears to be at the 'front' of the stack (in the example above, the fourth tab).
  4. The same applet is used to provide the bottom edge of the 'index cards'.
  5. In a Java-enabled browser, the applet is normally set so it automatically fits the full width of the browser window.
\_____/

Here's the NetRexx source, as a plain ASCII file. The compiled .class file is roughly the same size as the .gif 'banner' image at the top of this page.

You can also download the Tablet package (with the .class file already compiled from the source) in zip format [tablet.zip, 14kB]. The Tablet package is also included in the NetRexx package – you may prefer to download the whole package, including the other NetRexx samples and examples.

Please note that the Tablet package is part of the NetRexx package, and is covered by the terms in the IBM License Agreement for that package.


Using the Tablet applet

To have the applet displayed in a World Wide Web (HTML) page, you need to

  1. place the Tablet.class and tablet.gif files in the same directory as the page in which they are to be used (the small tablet.gif provides the prototype from which the tabs are constructed)
  2. refer to the applet, wherever you want it to appear on the page, with the <applet> tag, for example:
    
      <applet code="Tablet.class" width=100% height=40>
    
      <param name=tab1 value="News nrnews.html">
    
      <param name=tab2 value="Documentation nrdocs.html">
    
      <param name=show value="2">
    
      </applet>
    
    
    Here,
  3. To show the 'bottom edge' of the card, use:
    
      <applet code="Tablet.class" width=100% height=15>
    
      <param name=show value="0">
    
      </applet>
    
    
    Note that the height in the applet tag should be 15 in this case.

You can then view the HTML file that includes the applet tags with any Java-enabled browser.

If you do not have a Java-enabled browser, you can view the applet using the 'applet viewer' that comes with the Java Development Kit. To do this, change to the directory containing the World Wide Web (HTML) page that contains the reference to the applet, and issue the command


  applet testapp.htm

where 'testapp.htm' is the name of the page. This should start up the applet viewer, showing a window for each applet referenced from the page. [Note: the applet viewer may be called 'appletviewer' on some systems; also, you may need to change the '100%' in the width setting to a fixed number such as '500'.]

If you do not see the applet in the window, or the window does not appear, close the viewer (if necessary) and see if there are any messages in the applet viewer's 'weblog' file. This may be found in the 'applet' or 'weblogs' subdirectory which you should find in the Java home directory (e.g., d:\java, depending on where you installed Java).

Warning: the applet viewer takes a URL (e.g., http://etc...) or a plain file name. If you want to give it the name of a file that needs a path, prefix the file specification with 'file:/'. For example:


  applet file:/d:\fred\myapplet.htm

The format of the file specification will vary from platform to platform.

Compiling the Tablet applet

To compile the applet, ensure the 'Tablet.nrx' file (note the first letter is a capital letter) is in your current directory, and then enter the command:


  java COM.ibm.netrexx.process.NetRexxC Tablet

This 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 the class file for the applet.
This should leave a new Tablet.class file (and also a cross-reference listing, Tablet.crossref) in your current directory. The Tablet.class file can then be used for running the applet as described above. [Note: most browsers need to be restarted to load a new version of a class file.]

[ IBM | Help | Legal | Privacy ]