Scripting

From JAXXWiki

Scripting is the ability to embed Java code directly into JAXX files. The word 'scripting' usually implies that the code is interpreted at runtime, but JAXX scripts are compiled to ordinary Java bytecodes and so do not suffer any performance penalty. Following is a list of locations within JAXX files where Java code can appear.

Contents

Script tags

Java code may be embedded almost anywhere in JAXX files using the <script> tag. Script tags can define methods, fields, and constructors, and can also directly execute arbitrary Java code.

Data binding

Java code may appear in XML attribute values when escaped by curly braces ({ }). The attribute value is then computed using the Java code, and recomputed when its dependencies (if any) change. This usage of scripting is called data binding.

Event handlers

Within class tags, attributes whose names begin with on followed by a capital letter (e.g. onMousePressed, onActionPerformed) are event handlers. The attribute value is Java code which runs when the event is fired.

Constraints attribute

On components, the constraints attribute specifies the layout constraints (e.g. BorderLayout.NORTH, GridBagConstraints) that should be used when the component is added to its parent container. The value of this attribute is Java code which is evaluated at component creation time.

ConstructorParams attribute

Within class tags, the constructorParams attribute specifies comma-separated parameters to the object's constructor. These parameters are interpreted as Java code.