How to 'properly' extend javax.swing.JFrame with nashorn? (original) (raw)
Christian MICHON christian.michon at gmail.com
Tue Mar 3 11:39:01 UTC 2015
- Previous message: How to 'properly' extend javax.swing.JFrame with nashorn?
- Next message: Nashorn in JDK 8u40
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Sundar,
thanks for the explanation. I was already doing what you suggested, and I wanted to do it the way I'm used to (without "my." within a sub-class extension).
Nevermind: nashorn is still a great tool.
On Tue, Mar 3, 2015 at 11:50 AM, A. Sundararajan < sundararajan.athijegannathan at oracle.com> wrote:
Are you looking for a way to introduce a new constructor? That is not supported. The class extension in nashorn is more like Java anonymous classes - There too you don't introduce a new constructor - just use existing constructor to construct new object.
You can workaround with: function createMyFrame() { var my = Java.extend(.....) { ... } my.setSize(800, 600); my.visible = true; return my; } -Sundar
Christian MICHON wrote: 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
-- Christian
- Previous message: How to 'properly' extend javax.swing.JFrame with nashorn?
- Next message: Nashorn in JDK 8u40
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]