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
Posts: 74
Registered: ‎07-17-2008
My Device: Not Specified
Accepted Solution

LabelField and Seperator field in a HorizontalFieldManager

Hey there,

I'm trying to get a LabelField and a Seperator field concatinated, so i can have a caption followed by a seperator line

 

like:

Caption ---------------------

 

 

The problem is that when i add the seperator line after the label, i just cant see it at all.

any idea on what should i do?

 

thanks...

Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: LabelField and Seperator field in a HorizontalFieldManager

Try something like this:

 

LabelField label = new LabelField("Caption "); final int labelWidth = label.getPreferredWidth(); SeparatorField separatorField = new SeparatorField() { public int getPreferredWidth() { return Display.getWidth() - labelWidth; } protected void layout( int width, int height ) { super.layout(getPreferredWidth(), getPreferredHeight()); setExtent(getPreferredWidth(), getPreferredHeight()); } };

HorizontalFieldManager hfm = new HorizontalFieldManager(Field.USE_ALL_WIDTH); VerticalFieldManager vfmLeft = new VerticalFieldManager(); VerticalFieldManager vfmRight = new VerticalFieldManager(Field.FIELD_VCENTER); vfmLeft.add(label); vfmRight.add(separatorField); hfm.add(vfmLeft); hfm.add(vfmRight);

 

Regards

Bikas

 

 

Developer
Posts: 74
Registered: ‎07-17-2008
My Device: Not Specified

Re: LabelField and Seperator field in a HorizontalFieldManager

[ Edited ]

Never mind, It works great :-)

I tried it with RichTextBox and it didnt work with that for some reason.

 

Message Edited by omri on 07-07-2009 02:03 AM
Highlighted
Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: LabelField and Seperator field in a HorizontalFieldManager

I just checked your code. Now I see you deleted that code.

Some comment about your deleted code. Smiley Happy

1. override the layout() of your RichTextField for setting its width and height 

2. use two vertical manager(one for rich text and another for separatorField).

3. add the vertical mangers into one horizontal manager.

 

By the way, if your problem solved. Then please resolve the thread.

 

Regards

Bikas