BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   set height LabelField (http://www.blackberryforums.com/developer-forum/208063-set-height-labelfield.html)

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
Code:

            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 05:29 AM.

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