Welcome!

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

Show focus changes using BitmapField

by Retired ‎02-16-2010 02:55 PM - edited ‎09-16-2010 03:50 PM (4,991 Views)

Summary

 

This article applies to BlackBerry® wireless devices based on Java™.

 


Description

 

A BitmapField can handle focus changes in a similar fashion to other fields in the BlackBerry application programming interface (API) set. When in focus, a BitmapField does not draw a border around the field to show it has focus. Instead, the transparent regions of the image are highlighted, in the same manner as the selected icons on the BlackBerry device Home screen. If you want to visually represent the focus status of a BitmapField, the image used in the BitmapField must contain a transparent area.

 

Another option to create a visual indication of focus changes is to override the onFocus and onUnfocus methods and provide custom visual indication, such as changing the bitmap shown in the field. The following code sample depicts how to change the bitmap of a Bitmap field when it gains or loses focus.

 

 

Bitmap bm1 = Bitmap.getBitmapResource("focusImage.png");
Bitmap bm2 = Bitmap.getBitmapResource("unFocusImage.png");

BitmapField bmField1 =
 new BitmapField(bm1,BitmapField.FOCUSABLE)
{
    public void onFocus(int direction)
    {
        setBitmap(bm2);
    }

    public void onUnfocus()
    {
        super.onUnfocus();
        setBitmap(bm1);
    }
};

 

Contributors
Users Online
Currently online: 17 members 1,519 guests
Please welcome our newest community members: