[Reposted from m.d.t.js-engine where I mistakenly posted it first.]

Hi.

I want to, from script, extend a Java class that has no default
constructor.  Specifically, I want to extend javax.swing.OverlayLayout
so that I can override some of its methods.  I tried:

  Rhino 1.7 release 3 PRERELEASE 2009 03 04
  js> new JavaAdapter(javax.swing.OverlayLayout, { })
  Exception in thread "main" java.lang.NoSuchMethodError:
  javax.swing.OverlayLayout: method <init>()V not found
          at adapter1.<init>(<adapter>)
          ...

so obviously I need a way to provide a constructor in my class so that I
can call super and provide an argument.  Is there a way I can do this,
or will I have to extend OverlayLayout from Java?

Also, having the NoSuchMethodError quit the shell doesn't look good.
Maybe there can be a 'catch (NoSuchMethodError e)' at
src/org/mozilla/javascript/JavaAdapter.java:216 that throws some kind of
Exception.

Thanks,

Cameron

[PS: Actually, after I misposted this originally in m.d.t.js-engine, I
realised that I don't actually want to extend OverlayLayout; I need to
call setAlignmentX() on the components in the container.  But extending
a class with no default constructor is something I've wanted to do
before, so the question still remains.]

-- 
Cameron McCormack ≝ http://mcc.id.au/
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to