previous up next
Go backward to 2.4 Compiling the Program
Go up to 2 Using the Toolkit
RISC-Linz logo

2.5 Writing Applets

An application developed with the DAJ toolkit can be embedded as an applet into a Web page using the APPLET tag. The applet can be customized by the parameters specified below:

<APPLET code="C.class" width=w height=h>
  <param name=buttonLabel value=string>
  <param name=fontName value=string>
  <param name=fontStyle value=string>
  <param name=fontSize value=int>
Please enable Java!
</APPLET>

The applet loads class C.class; it appears as a button of width w and height h. The default label on the button is the title specified in the constructor of the corresponding Application object; this label may be overridden by the applet parameter buttonLabel.

The font used for the button label may be customized using the applet parameters fontName, fontStyle, and fontSize, each of which is optional and must determine a corresponding Java font.

When writing applet code, please keep in mind that most current commercial browsers (e.g., Netscape Communicator 4.0) only provide reliable support for Java 1.0.x. Do not yet use Java 1.1.x if you want to write applets that can be executed by a variety of browsers.

For installing an HTML file including a DAJ applet on a Web server, one has to make sure that the corresponding DAJ classes are appropriately installed and served:

  1. Java 1.0.x: install directory daj (with subdirectory awt) in some location of the Web server and make sure that all .class files in these directories are served with Content-Type application/octet-stream.

    E.g., under the WN server, this is achieved by putting a file index into directories daj and daj/awt with contents

    Default-Content=application/octet-stream
    Attribute=serveall
    
    and calling wndex within each of both directories.

    The applet has then to specify the attribute codebase to denote the URL of directory daj, i.e.,

    <APPLET code="C.class" 
      codebase="url" 
      width=w height=h>
    </APPLET>
    

    You may omit the codebase attribute only if you install the directory daj in the directory of the HTML file containing the applet.

  2. Java 1.1.x: as explained above, Java 1.1 is not yet properly supported by most current commercial browsers.

    However, when this support becomes available, the programmer may combine all the newly defined Java classes of his DAJ application into a Java archive (JAR) file a.jar by calling e.g.

    jar cvf a.jar *.class
    
    This archive has to be installed together with the DAJ archives daj.jar and awt.jar in a directory served by the Web server making sure that these files are served with Content-Type application/java-archive.

    E.g. under the WN server, this is achieved by putting a file index into this directory with contents

    Attribute=serveall
    Default-content=application/java-archive
    
    and calling wndex within this directory.

    The applet then has to specify the attributes codebase and archive to denote the URL of the directory containing the JAR files and the names of the files, respectively:

    <APPLET code="C.class" 
      codebase="url" archive="a.jar, daj.jar, awt.jar"
      width=w height=h>
    </APPLET>
    

Maintainer: Wolfgang Schreiner
Last Modification: November 14, 1997

previous up next