Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

UI components

UI components are the items you can put on a screen. The net.rim.device.api.ui.component package provides a library of prebuilt components and controls.

Add a UI component to a screen

  1. Import the following classes:

    • net.rim.device.api.ui.component.CheckboxField
    • net.rim.device.api.ui.container.MainScreen
  2. Create an instance of a UI component, in this example a checkbox.

    CheckboxField myCheckbox = new CheckboxField("First checkbox", true);
    
  3. Add the UI component to your extension of a Screen class.

    mainScreen.add(myCheckbox);
    

Aligning a field to a line of text

You can align a Field object to the natural beginning of a line of text with the Field.FIELD_LEADING flag. For example, if you create a Field with the alignment flag Field.FIELD_LEADING and add the Field to a VerticalFieldManager, then if the application starts using English or Chinese locales, the Field aligns to the left side of the screen. But if the application starts using Arabic or Hebrew locales, the Field aligns to the right side of the screen.