Storing / retreiving a custom control


I’ve got the following two methods in my control:



public void read(JmeImporter im) throws IOException {;

InputCapsule ic = im.getCapsule(this);


template = ENTITY_TEMPLATES.valueOf(ic.readString(“template”, null));




public void write(JmeExporter ex) throws IOException {


OutputCapsule oc = ex.getCapsule(this);

oc.write(, “template”, null);



This is on my Control which in turn extends AbstractControl. In here, I first call the corresponding supre methods, which in turn should write / read the spatial in the control. But in the read method, the System.out returns null for the getSpatial…

Anyone have any idea what could be causig this, and how I fix it?


getSpatial returns the spatial on wich the control is attached. the control is not yet attached when the read method is called.*

You must call




in the setSpatial method of your control. (just override it)