Hi there,

I keep seeing the following error while trying to implement an actionlistener:

"org.mozilla.javascript.EvaluatorException: error instantiating (Wrapped java.lang.NullPointerException (test.js#5)): class java.awt.event.ActionListener is interface or abstract (test.js#5)"

Can anybody see what's wrong with my code below?

Thanks!


[ script ]
function Test()
{
   var btn = new javax.swing.JButton("Test");
var obj = { actionPerformed: function() { javax.swing.JOptionPane.showMessageDialog(null, "test"); } }
   var al = new java.awt.event.ActionListener(obj);    // <= Exception
   btn.addActionListener(al);
}


[ java ]
try
{
   Context cx = Context.enter();
   Scriptable scope = new ImporterTopLevel(cx);
Object res = cx.evaluateReader(scope, new FileReader("test.js"), "test.js", 1, null);
   Object fObj = scope.get("Test", scope);
   if (fObj instanceof Function)
   {
       Object functionArgs[] = {};
       Function f = (Function) fObj;
       Object result = f.call(cx, scope, scope, functionArgs);
   }
}
catch (Exception ex)
{
   JOptionPane.showMessageDialog(null, ex.toString());
}
finally
{
   cx.exit();
}

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to