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
Contributor
Posts: 17
Registered: ‎08-27-2013
My Device: Blackberry Torch 9860

Setting margin of a field in the paint() method

Hi All,

 

I am working on a blackberry field, it's working well, but i need to setMargin of the field in relative to others if the blackberry is tilted. 

 

Is it possible to set the margins in the paint method, because the tilt invokes the layout() method, which invokes invalidate().

 

 

Thanks

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

Re: Setting margin of a field in the paint() method

paint() should only paint - it should not change the layout of the Field.

 

The place to alter positioning of Fields is in the Manager's sublayout.  sublayout is called when the device is tilted.

Contributor
Posts: 17
Registered: ‎08-27-2013
My Device: Blackberry Torch 9860

Re: Setting margin of a field in the paint() method

after implementing the sublayout() method, the fields added to the manager was removed.
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Setting margin of a field in the paint() method

Removed - or moved somewhere that is not visible?

 

Also, sorry, I should have given you more in my previous post.  You should not do a setMargin in sublayout either.  You should use sublayout to positin your Fields directly, whihc is possibly a little complicated, but see these KB articles for more:

 

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

 

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749