TOC PREV NEXT INDEX



Cleaning up


You have finished placing most of the components that you will need for the simple tip calculator. You will now go through your GUI and clean up the components you created. First you will set up the labels of the text fields.

  1. Click on the first text field that appears below the form in the Parts tree. You will see the Properties page for this TextField appear to the right in the Composer.
  2. Change the Item label to 'Bill Amount $'. Note that the changes are shown immediately in the Emulator.
  3. Each component is given a name which you use to refer to it when you write Java code. The current Object name is set to 'textField1' or 'textField2'. Change it to a simpler, more descriptive name, 'amount'.
  4. Remove the text in the Starting text box so that it is blank.
  5. TextFields can be set up with certain input constraints. Since the bill amount must always be a number, choose 'Numeric' from the list of Constraints. If you do not see the Constraints, you may need to resize the Composer window or adjust the size of the contextual help.
  6. To edit the properties of the next TextField, click on it in the Parts tree. It will be the TextField below 'amount' in the tree.
  7. Change the Item label to 'Percentage'. Change the Object name to 'percentage'. Remove the text in the Starting text box, and choose 'Numeric' from the list of Constraints.
  8. Choose the StringItem in the Parts tree.
  9. Change the Item text to 'tip', the Item label to '$', and the Object name to 'tip'.

You have now set up most of the GUI for the Tip Calculator. Next you must add a Command, which will be a button in your application to calculate the tip.

  1. Click on the 'Commands' tab of the Palette. There is only one item on this page, the Command.
  2. Drag a Command to the form node in the Parts tree. It is not important where this command appears with relation to the other items, since Commands are all displayed at the bottom of the screen. A new Command with a name similar to 'command1' will be added to the tree, and a button with the same name will appear in the Emulator. Each new Command has two nodes created automatically underneath it: 'Code Before' and 'Code After'.
  3. Change the Command label of the command to 'compute tip'

Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX