import java.applet.Applet; import java.awt.*; import java.util.*; import java.net.*; import java.io.*; import netscape.javascript.*; /** * * DocWriter (C) 1996 by Paul A. Houle (ph18@cornell.edu) * * DocWriter, like many good things in life, is free. You can find out * more about DocWriter at * * http://www.msc.cornell.edu/~houle/javascript/DocWriter.html * * DocWriter uses LiveConnect to output a table of sines, cosines, and * tangents to another browser window. The user can then print the results * or save them to a file. LiveConnect is only available on Netscape 3.0 * as of the time of this writing. * */ public class DocWriter extends Applet { Button GoButton; JSObject mozilla; public void init() { setBackground(Color.white); GoButton = new Button("Go!"); add(GoButton); }; public boolean action(Event evt,Object what) { if (evt.target==GoButton) Go(); return false; }; void Go() { double angle; mozilla=JSObject.getWindow(this); mozilla.eval("myWindow = window.open('','displayWindow')"); mozilla.eval("myWindow.document.open('text/html')"); WriteDoc("
| Angle | Sin | Cos | Tan |
| "+i+" | "); WriteDoc(""+Math.sin(angle)+" | "); WriteDoc(""+Math.cos(angle)+" | "); WriteDoc(""+Math.tan(angle)+" |