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

Reply
New Developer
Posts: 44
Registered: ‎08-06-2009
My Device: Not Specified

getField() getWidth() etc methods returning '0' for fields

Hello,

 

I am using a custom layout manager and trying to relatively offset positions of fields based on their width and height. I have  tried calling Field.getWidth()  and Field.getHeight() from both in the custom layout manger and from my main class, but I get a return value of '0' for almost all cases.  The only time so far I can tell that the correct width and height are returned,is after the fields are placed within the manager, which means they are not in the correct position.

 

Thank you for any help.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: getField() getWidth() etc methods returning '0' for fields

I think what you are seeing is expected.  How can a Field have a size if it has not been laid out?  I think you should use getPreferred....
Highlighted
New Developer
Posts: 44
Registered: ‎08-06-2009
My Device: Not Specified

Re: getField() getWidth() etc methods returning '0' for fields

[ Edited ]

Thank you.  Instead of the getWidth() and getHeight() methods, I tried using Field.getExtent() in the custom layout manager sublayout() method and it is workin.

 

This is before calling setPositionChild()*edit*, so I am not sure why the getHeight() and getWidth() don't work while this way does.

Message Edited by adisonjames on 09-04-2009 07:30 PM