// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package htmldemo;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.swing.JApplet;

import org.w3c.dom.html.HTMLDocument;
import org.w3c.dom.html.HTMLInputElement;

public class NewStyle extends JApplet {
	public void calc() {
        try {
			Class<?> c = Class.forName("com.sun.java.browser.plugin2.DOM");
			Method m = c.getMethod("getDocument", new Class[] { java.applet.Applet.class });
			HTMLDocument doc = (HTMLDocument)m.invoke(null, new Object[] { this });
	         HTMLInputElement myfield1 = (HTMLInputElement)doc.getElementById("myfield1");
	         HTMLInputElement myfield2 = (HTMLInputElement)doc.getElementById("myfield2");
	         HTMLInputElement myfield3 = (HTMLInputElement)doc.getElementById("myfield3");
	         int val1 = Integer.parseInt(myfield1.getValue());
	         int val2 = Integer.parseInt(myfield2.getValue());
	         int val3 = val1 + val2;
	         myfield3.setValue(Integer.toString(val3));
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}
}
