Host Graphics Now
Cartesian Text Demo 1
John's Home Page

Text Demo 1
HTML Source
Put this HTML code anywhere on an HTML page.  It will call the Java applet NetscapeApplet, which will then call the Java application TextDemo1.  WIDTH and HEIGHT define the size of the applet on the page. 
<APPLET CODE="NetscapeApplet" WIDTH=100 HEIGHT=100>
  <PARAM NAME="ApplicationClass" VALUE="TextDemo1">
  Your browser does not support Java applets
</APPLET>
NetscapeApplet
NetscapeApplet is part of the Netscape Internet Foundation Classes. 
TextDemo1 Source
This is the Java code for the application.  The init method sets TextDemoView1 as the (only) view for the application.  TextDemoView1 must be compiled before TextDemo1 can be compiled.
import netscape.application.*;
import TextDemoView1;

public class TextDemo1 extends Application {
  static int Width;
  static int Height;

/** For a java applet, only the init ()
    method is required.
*/

  public void init () {
    super.init ();
    TextDemoView1 Canvas = new TextDemoView1 (100, 100);
    mainRootView().addSubview (Canvas);
  }

/** Providing a main (String) method allows 
    the application to be run also as a Standalone.
*/

  public static void main (String [] args) {
    Width = 100;
    Height = 100;
    TextDemo1 App = new TextDemo1();
    ExternalWindow MainWindow = new ExternalWindow();
    App.setMainRootView (MainWindow.rootView());
    Size size = MainWindow.windowSizeForContentSize
                  (Width, Height);
    MainWindow.setBounds (0, 0, size.width, size.height);
    MainWindow.show ();
    App.run ();
    System.exit (0);
  }
}
TextDemoView1 Source
This is the Java code for the view.  The constructor establishes the size, and the drawView method draws the Text. 
import netscape.application.*;
import Cartesian.*;

public class TextDemoView1 extends View  {

/** The constructor sets the dimensions of the view.
 * @param Width View Width
 * @param Height View Height
*/
  public TextDemoView1 (int Width, int Height) {
    super (0, 0, Width, Height);
    setBuffered (false);
  }

/** The drawView method is
 *  where the actual drawing is done.
 * @param Display Graphics context
*/
  public void drawView (Graphics Display) {
    Cartesian Canvas 
      = new Cartesian (Display, localBounds());
/* Declare the point */
    C_Point Position = new C_Point (10, 30);
/* Begin drawing calls */
    Canvas.Text (Position, "Hello, World");
/* End drawing calls */
  }
}
The applet:
Your browser does not support Java applets
Text Demo 1
Demo Applet Source:
Text Page
See Also:
Cartesian Points
Cartesian Class


Cartesian Index
Go To Graphics Now Home Page
©1999, J.H.Young E-Mail Me

1