You can create JavaScript objects that contain the state and implement the behavior of a control. The controls take care of drawing themselves, including changing their appearance as a result of various state changes.
Create JavaScript to add screen controls. The following example adds a text box and a button.
var helloButton; var nameField; ... // Add a text box to the view nameField = new TextField(null, "Enter your name"); mainView.addControl(nameField); // Add a button to the view helloButton = new FormButton(null, "Say Hello!"); helloButton.addEventListener("ActionPerformed", helloButtonClicked); mainView.addControl(helloButton);
Figure: Hello World widget