From 20c82f88e9fd159782c505003505f414d268139a Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Tue, 5 Dec 2000 16:42:39 +0000 Subject: [PATCH] Add construction of Counter from Java --- js/rhino/examples/RunScript3.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/rhino/examples/RunScript3.java b/js/rhino/examples/RunScript3.java index c3e9d4e26e3d..5653d6aede29 100644 --- a/js/rhino/examples/RunScript3.java +++ b/js/rhino/examples/RunScript3.java @@ -50,6 +50,14 @@ public class RunScript3 { // Use the Counter class to define a Counter constructor // and prototype in JavaScript. ScriptableObject.defineClass(scope, Counter.class); + + // Create an instance of Counter and assign it to + // the top-level variable "myCounter". This is + // equivalent to the JavaScript code + // myCounter = new Counter(7); + Object[] arg = { new Integer(7) }; + Scriptable myCounter = cx.newObject(scope, "Counter", arg); + scope.put("myCounter", scope, myCounter); String s = ""; for (int i=0; i < args.length; i++)