title: Duplicating custom nodes in JavaFX
body: <p>As far as I understand, duplicating nodes in JavaFX should be done with the <code>Duplicator.duplicate</code> function.</p>
  
  <p>It works fine when duplicating nodes whose types are included in JavaFX library, for example</p>
  
  <pre><code>def dup = Duplicator.duplicate(Rectangle{x:30 y:30 width:100 height:100});
  dup.translateX = 10;
  insert dup into content;
  </code></pre>
  
  <p>would insert a black rectangle to the scene.</p>
  
  <p>However if I define a new class in the following way:</p>
  
  <pre><code>class MyRect extends Rectangle {}
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>class MyRect extends CustomNode {
      override function create() {Rectangle{x:30 y:30 width:10 height:10}}
  }
  </code></pre>
  
  <p>It gives me the following runtime error</p>
  
  <pre><code>Type 'javafxapplication1.NumberGrid$MyRect' not found.
  </code></pre>
  
  <p>Where of course <code>javafxapplication1.NumberGrid</code> are the package and file the <code>MyRect</code> class is in.</p>
  
  <p>This guy at <a href="http://forums.sun.com/thread.jspa?threadID=5391083" rel="nofollow noreferrer">Sun's forums</a> had the same problem, but I don't see any answer in there.</p>
  
  <p>Or maybe I'm doing that the wrong way, and there's a better approach for duplicating custom nodes?</p>
  
  <p><strong>update:</strong> Trying to duplicate <code>Group</code> worked, but trying to duplicate <code>Stack</code> yields the same error.</p>
  
  <p>According to the documentation, it's supposed to support all types supported in <code>FXD</code> including <code>Node</code>, but maybe it supports only some of <code>Node</code>'s descendants?</p>