BlackBerry Forums Support Community

BlackBerry Forums Support Community (
-   Developer Forum (
-   -   set height LabelField (

mabin 10-22-2009 08:31 AM

set height LabelField
I have been searching for an example of how to set the height of a label field. I have read that you need to extend the class and override getPreferredHeight(). How would you do this? I have tried the following

            LabelField lbl_overview = new LabelField("Overview",LabelField.FIELD_HCENTER)
                public int getPreferredHeight(){
                    return 200;

Which is wrong, as all I am doing is returning a height. Does any one have a simple example?

rachnakhokhar 10-23-2009 02:59 AM

Hi Mabin,

You are doing right by overriding this method but you haven't told this label field to take your given height you have to use setExtent method to give your preferred height.

renuka_anil 10-26-2009 07:51 AM

set height LabelField
try this

protected void layout(int width, int height){
super.layout(lblWidth, lblHeight);
setExtent(lblWidth, lblHeight);

lblWidth is width of the label
lblHeight is height of label

both are calculated..

All times are GMT -5. The time now is 10:49 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.