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

BlackBerry® World™ Development

Reply
Highlighted
Regular Contributor
Posts: 55
Registered: ‎09-01-2010
My Device: Not Specified

Buttonfield getPreferredWidth problem

I have created a Buttonfield and a custom getPreferredWidth() method for that. Here is my code.

 

HomeButton = new ButtonField("Back", FIELD_LEFT | ButtonField.CONSUME_CLICK | USE_ALL_WIDTH){

     public int getPreferredWidth() {

        return getFont().getAdvance("Back") + 15;

    }

};

 

int buttonWidth = HomeButton.getPreferredWidth();

 

When I am calling the method getPreferredWidth() for the button field, it is giving no error during compilation, but it is throwing runtime exception when I am trying to run the application. Can anyone tell me where is the problem in my code?