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

Posts: 46
Registered: ‎10-29-2008
My Device: 9700

FlowFieldManager - force new line?

I have a FlowFieldManager that I dynamically add a bunch of [net.rim.device.api.ui.]Fields to...that are simply text.  They are varying size in length and I'm seeing an issue with it not wrapping the way that I would like.  


The behavior I'm getting is that if the field has enough space to "start" drawing on (towards the end of) a row (line), it will...EVEN IF part of it gets cut off from the preferred width of the Manager.  The field added after WILL get placed on the next line.


Obviously I don't want to have the field only partially visible on the screen, so the way I see it, I need to either:

a.  force it somehow to the next line (of the flowfieldmanager) if there's not enough space  (not sure there is a way to do that)

b.  hack it so that once I determine the available space on the row, throw in a dummy field so that the proper next field will break to the next line.

c.  change the Field to some other field type that will wrap in the flowfieldmanager appropriately (?possible?) 


any ideas? thank you.



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

Re: FlowFieldManager - force new line?

I don't think I've seen FlowFieldManager display in the way you describe - i.e. put a Field in that is only partially visible.  Can you supply a simple test case that I can have a go at to see if I can help with this?


Have to say all your options a, b and c look difficult to me!  I'd rather try to get FlowFieldManager working the way I think it is supposed to work!

Posts: 11
Registered: ‎02-16-2010
My Device: 10k
My Carrier: Sim

Re: FlowFieldManager - force new line?

Shinebox, I have encountered the exactly same problem. To solve it, I created the following wrapper manager around FlowFieldManager to limit its width.



import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.container.FlowFieldManager;

 * When FlowFieldManager lays out fields in a row, as long as there is enough space to start
 * drawing the next field, it will draw the field and cause the field to be cut off horizontally.
 * This wrapper lays out a FlowFieldManager with custom width to compensate for the cutoff.
public class FlowFieldManagerWrapper extends Manager {

	private final int width;
	private final FlowFieldManager flowFieldManager;

	public FlowFieldManagerWrapper(FlowFieldManager flowFieldManager, int width) {
		this.flowFieldManager = flowFieldManager;
		this.width = width;

	protected void sublayout(int width, int height) {
		layoutChild(flowFieldManager, this.width, height);
		setPositionChild(flowFieldManager, 0, 0);
		setExtent(this.width, flowFieldManager.getHeight());

 If the fields you are inserting to the FlowFieldManager are all the same width, then you can pass to the wrapper (intended FlowFieldManager width - field width) to compensate for the cut off.


Also I pass in the width in the constructor of FlowFieldManagerWrapper, because the wrapper is not used in a custom Manager. If you are using a custom Manager, you can modify the implementation to use the width parameter passed in the sublayout method instead.


There are likely better and more elegant solutions for this. I would appreciate it if fellow BlackBerry developers can share them.


Posts: 1
Registered: ‎04-14-2010
My Device: n/a
My Carrier: n/a

Re: FlowFieldManager - force new line?

[ Edited ]

As stated in http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/Field.html#getPreferredWidt... some managers (like the FlowFieldManager) use getPreferredWidth() in the layout process. Override it and the wrapping should be the way you expected it to be.