topical media & game development
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

java-jsobject.jva

java-jsobject.jva / java-jsobject


  import java.applet.Applet;
  import java.lang.*;
  import netscape.javascript.JSException;
  import netscape.javascript.JSObject;
  
  public class simple_applet extends Applet
  {
    JSObject win, doc, form, field;
  
     public void init()
    {
      // BE CAREFULL : the form must have been define before the applet starts
      //               --> <APPLET> tag must be embeded after the form 
      win = JSObject.getWindow(this);
      doc = (JSObject)win.getMember("document");
      form = (JSObject)doc.getMember("the_form");
      field = (JSObject)form.getMember("the_field");
     }
  
    public void upper()
    {
      String text  = (String)field.getMember("value");
      System.out.println("Text = " + text);
      field.setMember("value", text.toUpperCase());
    }
  
    public void lower()
    {
      String text  = (String)field.getMember("value");
      System.out.println("Text = " + text);
      field.setMember("value", text.toLowerCase());
    }
  }
  


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.