Configure a browser field

  1. Import the required classes and interfaces.
    import net.rim.device.api.browser.field2.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.container.*;
  2. Create the application framework by extending the UiApplication class. In main(), create an instance of the new class and invoke enterEventDispatcher() to enable the application to receive events. In the application constructor, invoke pushScreen() to display the custom screen for the application. The BrowserFieldDemoScreen class, described in step 3, represents the custom screen.
    public class BrowserFieldDemo extends UiApplication
    {
         public static void main(String[] args)
         {
              BrowserFieldDemo app = new BrowserFieldDemo();
              app.enterEventDispatcher();
         }
    
         public BrowserFieldDemo() 
         {
              pushScreen(new BrowserFieldDemoScreen());
         }
    }
  3. Create the framework for the custom screen by extending the MainScreen class.
    class BrowserFieldDemoScreen extends MainScreen
    {
         public BrowserFieldDemoScreen()
         {
         }
    }
  4. In the screen constructor, create an instance of the BrowserFieldConfig class.
    BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
  5. In the screen constructor, invoke BrowserFieldConfig.setProperty() to specify a property of the BrowserField. The first parameter in setProperty() specifies the property, and the second parameter specifies the value of the property. For example, the following code sample specifies the NAVIGATION_MODE property of a BrowserField object:
    myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
    BrowserFieldConfig.NAVIGATION_MODE_POINTER);
  6. In the screen constructor, create an instance of the BrowserField class that uses the configuration that you defined.
    BrowserField browserField = new BrowserField(myBrowserFieldConfig);

Was this information helpful? Send us your comments.