How to 'properly' extend javax.swing.JFrame with nashorn?

Christian MICHON christian.michon at gmail.com
Tue Mar 3 08:27:41 UTC 2015


Hi,

[ I tried to contact Sundar directly (still no answer), but I'd like to get
nashorn devs opinion as well. ]

I'm currently trying to extend a javax.swing.JFrame to make a small gui
using nashorn.

When I'm doing this with java or jruby, it's straight forward and quite
easy to code a contructor of the derived class to customize dimensions for
example.

Yet with nashorn I'm struggling: how is named the constructor?

I've a small snippet below to share: I'd like to know what is supposed to
be in place of XYZ to make frame appear properly (dimensions 800x600).

var myJFrame = Java.extend(javax.swing.JFrame, {
  XYZ: function() {
    setSize(800, 600);
    setVisible(true);
  }
});
var my = new myJFrame();
java.lang.Thread.currentThread().join();


Thanks in advance.
Christian


More information about the nashorn-dev mailing list