class HelloWorld { dj Button bt{text=="Hello World!"}; }This program defines a class called ``HelloWorld''. The line starting with dj is called a dj-field declaration. It declares a field called ``bt'', an instance of the base class Button. The expression in the brackets after bt is called a constraint that constrains the value of the text attribute of bt to be ``Hello World''.
Dj-fields are single-assignment variables. Each dj-field is the name for some particular object that is created automatically when an instance of the encapsulating class that owns the field is created. Unlike a member variable in Java, a dj-field cannot be updated and the object it refers to does not need to be created by calling a constructor.
In our example, nothing is said about the color and size of the button, the font of the text, and the position of the button in the main panel. we can but do not have to give the values to these attributes. The system will determine the attribute values for us either by using the constraints we provided or by using the default values.
We call a dj-field a component if it is visible; otherwise, we call it an attribute. In our example, bt is a component and the text field of bt is an attribute.