Component Cloning

All components are cloneable. In other words, they are implemented java.lang.Cloneable. Thus, it is simple to replicate components as follows.

<vbox id="vb">
    <listbox id="src" multiple="true" width="200px">    
        <listhead>        
            <listheader label="Population"/>            
            <listheader align="right" label="%"/>            
        </listhead>        
        <listitem value="A">        
            <listcell label="A. Graduate"/>            
            <listcell label="20%"/>            
        </listitem>        
        <listitem value="B">        
            <listcell label="B. College"/>            
            <listcell label="23%"/>            
        </listitem>        
        <listitem value="C">        
            <listcell label="C. High School"/>            
            <listcell label="40%"/>            
        </listitem>        
    </listbox>    

    <zscript>    
    int cnt = 0;    
    </zscript>    
    <button label="Clone">    
        <attribute name="onClick">        
    Listbox l = src.clone();    
    l.setId("dst" + ++cnt);    
    vb.insertBefore(l, self);    
        </attribute>        
    </button>    
</vbox>