|Introduction | Your first interface | Building a model | Advanced features | Resources|
3.4 Finishing the model
When you have stepped through the thread support and custom objects screens, you will be able to view your generated code. The Wizard will look something like this:
The Wizard will create a java file:
The wizard creates the file structure with variables and methods, but you still have to do the work of actually coding the model. If you look at the code in the top panel you will see method stubs for the methods you have specified in the Model Wizard. Remember that the change methods will be called when a change is made at the interface to the property that calls it, the methods that are registered as action methods will be accessible with action buttons at the interface.
When you have finished, click Finish to save your file (it will be saved in the place you specified in Step 1 of the Model Wizard - in this case a folder called
Although the model file can be edited in the Model Wizard, it is just a standard Java file, so for large models it is often easier to save it oncde the initial structure is defined and then edit it into your usual Java text editor.
If you now navigate to the
Once you have your class file, it is ready to be imported into the Interface Builder. If you open the Interface Builder, then open the File menu, and the Import sub-menu, you can select Import Model. (If the Interface Builder is on the same computer that the Model Wizard is running on, the model will automatically be available.)
When asked to select a model file to open, you can navigate to your
Note: if you get a message that the file is already available, go to the Menu tab of the Configuration Editor (View, Preferences) and click Add. The simulation you've just imported will be available to add from the drop-down menu.
Congratulations! You've successfully created and imported your first model. You can update and recompile the model without having to re-import it into the Interface Builder, a restart will allow the updated model to be picked up. If you find at any point that your model won't load, it is most likely that there is an error in the property or action registration, and this is the first place to check.