views:

177

answers:

1

Hi all,

I am not getting clear about the concept of getPreferredWidth() and getPreferredHeight() methods. What do they return means on what what basis the values are returned.??

What is difference between getWidth() and getPreferredWidth()???

Thank you..

+5  A: 

By default, Field#getPreferredHeight() and Field#getPreferredWidth() return 0. They're there for your custom Fields to override with whatever your custom Field's preferred width/height is.

The value you supply in your overridden methods is then taken into consideration when it comes to laying out your Field. If your preferred values are suitable for the display area and your Field's content, then your preferred values will be used. These values are just suggestions.

Field#getHeight() and Field#getWidth() on the other hand return the actual extent of the Field.

Fostah