Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Create a Fixed Size BrowserField

by Retired ‎02-12-2010 04:13 PM - edited ‎09-16-2010 02:36 PM (2,539 Views)



This article applies to the BlackBerry® Java™ Development Environment 4.1.




This article customizes the BrowserFieldSampleApplication, provided with the BlackBerry Java Development Environment 4.1, to produce a fixed-size BrowserField. In the source file, add the following custom manager:



final class CustomManager extends VerticalFieldManager {
    CustomManager() {
       super(Manager.VERTICAL_SCROLL |Manager.VERTICAL_SCROLLBAR);
    public void sublayout(int maxWidth, int maxHeight) {
    super.sublayout(50, 50);


Note: The CustomManager is extending a VerticalFieldManager to leverage existing functionality. Important additions to the CustomManager include the Manager.VERTICAL_SCROLL and Manager.VERTICAL_SCROLLBAR style bits passed into the super constructor. The second important addition to the CustomManager is overriding the sublayout() method. The only change is to pass a fixed width and height into the super.sublayout().


The following modification in BrowserFieldSampleApplication is applied to the processConnection() method, which is responsible for adding the BrowserField to the screen:



synchronized (Application.getEventLock()) {

    _mainScreen.add(new LabelField("LabelField Above"));
    CustomManager manager = new CustomManager();
    _mainScreen.add(new BasicEditField("EditField Below:", ""));



Under the synchronized block, a new instance of the CustomManager is created, and the BrowserField is added to the CustomManager instead of the mainScreen. To also demonstrate the effect of the fixed-size manager, a LabelField is added above the BrowserField, and an EditField is added below the field.


In the above example, the size of the CustomManager is 50 x 50 pixels, which makes the BrowserField almost unreadable; however, the example demonstrates how a BrowserField can be reduced in size and added to a screen.

Users Online
Currently online: 7 members 792 guests
Please welcome our newest community members: