O'Reilly logo

BlackBerry Java Application Development by Bill Foust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - adding more to the MainScreen

You can continue by adding the constructor for the screen and setting up the rest of the fields. This constructor does a number of things to set up the screen. In general, it is creating and adding all of the screen elements that will be displayed.

  1. Add the following code to the TipCalcMainScreen class.
    public TipCalcMainScreen()
    {
    // Each screen can have a field in the Title section.
    LabelField title = new LabelField("TipCalc" , LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    // Set the title to the label.
    setTitle(title);
    // setup the EditField to accept the Bill Amount
    amount.setLabel("Bill Amount: $");
    // add the field to the screen
    add(amount);
    }
    
  2. Add the calculateTip method to the TipCalcMainScreen ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required