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
wpbbmg
Posts: 83
Registered: ‎02-19-2010
My Device: Not Specified

Size of FieldManager

[ Edited ]

Hello,

 

know I have another question! :smileysad:

 

I want to change the size from a HFM or VFM! I try it with sublayout() and with setExtent(). But I think the only value I set is the maximum width or height, but I want to set the permanent size of the manager. Know the manager is so wide like the field which is in it. Anybody understand me and can help me?

 

regards Maja

Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Size of FieldManager

Did you call setExtent before or after the call to super.sublayout?

Developer
wpbbmg
Posts: 83
Registered: ‎02-19-2010
My Device: Not Specified

Re: Size of FieldManager

Know I call setExtent() only!

 

 

public CustomVerticalFieldManager(long style, int width, int height){
	super(style);
	
	super.setExtent(width, height);
}
	
protected void paint(Graphics graphics)
{
    graphics.setBackgroundColor();
    graphics.setColor();
    graphics.clear();
    super.subpaint(graphics);
}

 

 

Developer
wpbbmg
Posts: 83
Registered: ‎02-19-2010
My Device: Not Specified

Re: Size of FieldManager

[ Edited ]

So ok maybe I can explain it a little bit more!

 

I want that it looks like:

 

-----------------------------------------------------------

|                                    |                                        |

|                                    |               Field1              |

|           Field                |                                        |

|                                    |               Field2              |

|                                    |                                        |

-----------------------------------------------------------

 

Know it looks like

 

-----------------------------------------------------------

|         |           |

|         |Field1|

|Field|           |

|         |Field2|

|         |           |

-----------------------------------------------------------

 

anybody an idea?

Developer
jMarc
Posts: 94
Registered: ‎10-01-2009
My Device: Not Specified

Re: Size of FieldManager

Here's a quick-and-dirty Manager that uses half the width of the screen.  You could put two of these in a HorizontalFieldManager and your layout would look like your picture.

 

NB: this is not necessarily good Manager design, it's just an example that works.

 

 

public class HalfWidthManager extends VerticalFieldManager {
    private int halfScreenWidth = Display.getWidth() / 2;
    protected void sublayout(int width, int height) {
	super.sublayout(getPreferredWidth(), height);
	setExtent(getPreferredWidth(), getPreferredHeight());
    }
    public int getPreferredWidth() {
	return halfScreenWidth;
    }
}

 

 

Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810

Re: Size of FieldManager

Can we set width and height of HFM and VFM object without subclassing them ?

 

Are there any methods that sets the width and height directly on objects of HFM and VFM .

 

HorizontalFieldManager mTitleFieldManager = new HorizontalFieldManager();

mTitleFieldManager.anyMethodToSetWidthOrHeight();

 

Any help ?

 

 

Always Success
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Size of FieldManager

"Can we set width and height of HFM and VFM object without subclassing them ?"

 

There are cases where you can set height to width, using style bits like USE_ALL_WDITH.  But these specific layout managers have been designed to take all the width (for HorizontalFieldManager, and height (for VerticalFieldManager) that they need.  Given this design criteria, the RIM developers did not feel it necessary to offer the methods you are suggesting.

 

However there is nothing stopping you writing your own manager that does this, or extending HFM or VFM to attempt to do this.  I suggest you try to write your own Manager, the effort of doing this will make you appreciate what is going on in the supplied Managers better too I think. 

 

"Are there any methods that sets the width and height directly on objects of HFM and VFM"

 

Pretty much the same comments apply to this question too.

 

Does this help or have I misunderstood the question? 

Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810

Re: Size of FieldManager

Hi peter

 

You got everything absolutely correct. Thanks for your reply.

It means we cannot provide hardcoded values (like   field.setwidth(100Units) or field.setHeight(100Units))  to the width and height properties of a particular field or manager. 


Yes will do the necessary subclassing.

Always Success