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
Developer
fonedev
Posts: 39
Registered: ‎04-09-2009
My Device: Not Specified
Accepted Solution

Set the position of a LabelField

Using JDE 4.5.

 

I need to set fields (LabelField, ButtonField, etc.) in arbitrary positions on the application screen.  The official methods that I have found seem to deal with left and right, but I need my fields to appear in other places.  I did get something that works though.  Here is the essence of my solution, where I place two Labels where I want them.:

 

verticalFieldManager = new VerticalFieldManager(...);
scrn.add(verticalFieldManager);
  
LabelField labelField = new LabelField("blah");
VerticalFieldManager vfm = new VerticalFieldManager();
vfm.add(labelField);
vfm.setPadding(25,0,0,100);
  
LabelField labelField2 = new LabelField("foo bar");
VerticalFieldManager vfm2 = new VerticalFieldManager();
vfm2.add(labelField2);
vfm2.setPadding(80,0,0,100);

verticalFieldManager.add(vfm);
verticalFieldManager.add(vfm2);

 

As you see, the secret sauce is setPadding() -- which I read about in these forums.  But it's undocumented...  Now of course I'm delighted to be a part of a secret cabal... But I wonder what is the official way of doing this.

 

Thanks for any help --fd

Please use plain text.
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Set the position of a LabelField

Hi,

 

Have a look at this link

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=3797&query.id=413...

 

this will help you.setPositionChild() is the method which should help you in achieving the desired result.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.
Developer
fonedev
Posts: 39
Registered: ‎04-09-2009
My Device: Not Specified

Re: Set the position of a LabelField

Hi Rajat,

 

I had found that thread, but I was hoping for something simpler.  On studying it more carefully though, I think I understand it, and it's not all that hard.  I'll give it a shot.

 

Thanks!  --fd

Please use plain text.
Contributor
agileball
Posts: 10
Registered: ‎03-10-2010
My Device: 9550
My Carrier: Vodaphone

Re: Set the position of a LabelField

I think setPadding and setMargin is very useful.

It makes life of GUI developer much easier than using setPosistionChild (which we have to create a wrapper manager). I just don't understand the implication of RIM when they try to remove those method (or at least make them deprecated and undocumented).

 

Is there any explanation for this behaviour from RIM?

 

Best,

 

Ball

Please use plain text.
Trusted Contributor
trupti
Posts: 242
Registered: ‎03-16-2010
My Device: 9530

Re: Set the position of a LabelField

 

Hi Rajat,

 

   I also have somewhat similar query & I think this is the only & the best way to add our components the way we want.

 

  But as mentioend in the link, they have buttonFields in the LayoutManager class itself. In my case, I want to add Labels, EditField & ButtonFields. All need to be listened, so need to add Listener. If they are declared in LayoutManager itself, how can I access them in my Screen class or add listener to them.

If I declare & initialize them in screen class, & add them in LayoutManager class, is that possible! Then I will have to set x, y locations for my all fields in sublayout(), correct. And then will I be able to access those components in the screen class too.

 

This is what is bothering me & am not able to find solution for the same. I want the components to be accessed in Screen & layout manager class.

 

 

Thanks for yout help & assistance.

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Please use plain text.