I try to create an instance of a class that extends a Java class, and in that instance add some class member variables. Here's my attempt:
var ui = Java.extend(javax.swing.JPanel, {
cb : new JCheckBox("A checkbox", true),
});
However, the Nashorn interpreter throws this error: "TypeError: function noSuchMethod() { [native code] } is not a constructor function"
What am I doing wrong? Nashorn didn't complain when I added an instance of a custom class, like se.datadosen.util.Stopwatch, but it throws this error when I try to add that JCheckBox.
(I know components are added to panels with the .add() call, but this question is really about how to add class member variables to a subclass.