Templates

Sometimes you might want to place several controls of the same type, each with the same properties. You could place each control and set their properties individually, or you could select multiple controls and then set all their properties at once as will be shown later in this tutorial, or you can create a custom widget template for that type of control. Custom widget templates allow you to save your own default properties for a control type. When a new control of that type is created, it will have the same properties that you set up. For example, if you wanted all of your check buttons to have a green foreground and a black background, you could set up a template to create all your check buttons like that.

In order to create a template, a control must first be placed. Set the properties of the control to the desired settings, then right-click on the control in either the Content Pane or the Control Tree and select Template > Save template. Now any control of that type that is created will have the properties from the template.

Templates menus  

Play movie. Requires a web connection.
Play Movie

To remove a template for a type of control, right-click on any control of that type and select Template > Clear template. Now if any new controls of that type are added, they will be created with the default properties. Clearing the template will not affect already placed controls.

You can also apply a template to any existing controls by right-clicking on a control whose type has a template and selecting Template > Apply template. The control will now have the properties saved in the template.

There are several properties that are not saved in a template. They are the events, layoutData, variable name, image, and items properties. The scope of a control (whether it is a local or a field) is also not saved.

The templates can be used in different files. The templates are saved even if you close Eclipse. You can create at most one template for each type of control.