![]() |
Graphics Now
Cartesian Line Demo 2 |
![]() |
| |||
NetscapeApplet is part of the Netscape Internet Foundation Classes. |
| ||||
This is the Java code for the application. The init method sets LineDemoView2 as the (only) view for the application. LineDemoView2 must be compiled before LineDemo2 can be compiled. | import netscape.application.*; import LineDemoView2; public class LineDemo2 extends Application { static int Width; static int Height; /** For a java applet, only the init () method is required. */ public void init () { super.init (); LineDemoView2 Canvas = new LineDemoView2 (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; LineDemo2 App = new LineDemo2(); 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); } } |
| ||||
This is the Java code for the view. The constructor establishes the size, and the drawView method draws the line. | import netscape.application.*; import Cartesian.*; public class LineDemoView2 extends View { /** The constructor sets the dimensions of the view. * @param Width View Width * @param Height View Height */ public LineDemoView2 (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 points */ C_Point A = new C_Point (10, 90); C_Point B = new C_Point (70, 20); /* Begin drawing calls */ Canvas.Line (A, B); /* End drawing calls */ } } |
The applet: |
Line Demo 2 |
Demo Applet Source: | ||||
|
See Also: | ||||
|
|
![]() |
![]() |