CIS 790                JAVA PROGRAMMING          PROF. AUCIELLO

Topics:     Applets -- Java Programming running inside Web Browser.
            HTML to run Applets.

av.exe (AppletViewer)    ... local viewer for applets.  (can use
			     Netscape for same function.) (source code)    ... (below).  From the source code,  a  'class'
                             is created.
xx.html (contains applet) .. (below).  The HTML contain the 'class',
                             and it executes (runs) the program (applet).

xx.class                 ... ('compilation of, embedded in wa.html)

Procedure:   Compile program ''  (below)
             Verify that     'gena.class' was created.
             Create          'gena.htm'   (below)
             Insert          'gena.class' into it.
             Test   using    Netscape     to load and run 'gena.htm'


[should see 2 lines of text in different colors and fonts.]

Here is the  source code:

/* WEEK 8                                       PROF. AUCIELLO

         use gena.html to execute 
         print results.  put in notebook.

        .      Printing a literal string.
               (using drawstring)
        .      'public'
        .      x (hor) and y (ver) coord for drawString
        .      Fonts

 Hello World, the first Java application 
-------------------------------------------  */

     // HelloWorld as an Applet 

   import corejava.*;             // req. for applet
   import java.awt.Graphics;      // req. for app & prog
   import java.awt.*;
     //  import java.awt.color;

public class gena extends java.applet.Applet // req for app
  { public void paint(Graphics g)   // req for app
    { Font f = new Font("Sans Serif", Font.BOLD, 14);   // define Font
         // Font is an object.  Need to define the 'properties' of Font,
         // (BOLD, Sans Serif, 14, etc).
         // Font f defines Font.

      g.setFont(f);    // setFont is part of the graphics 'library'
                      // setFont is now 'linked' with the program.

         // g.setColor(;

      g.setColor(new Color(0,128,128));
        // g.setColor(;
        // g.drawString(x,1,100);

      g.drawString("Hello World (color & motion!) @ hor 1, ver 150 ",1,150);
      g.drawString("Genesis Applet -- by drawString @ hor 1, ver 200 ",1,200); 

// gena uses drawString to display text, demos fonts and color!


Here is  gena.htm   (note it uses  gena.class)

[APPLET CODE="gena.class" WIDTH=400 HEIGHT=300 IGNORE=""]

100 Points - change color, message, fonts, print out.