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
New Developer
jsdf
Posts: 32
Registered: ‎04-30-2009
My Device: Pearl 8120

LabelField limited to N lines?

Hi all,

Does anyone have strategies or sample code that could be used to limit a LabelField to no more than N lines?  Any text longer than N lines would result in DrawStyle.ELLIPSES.

I imagine this involves overriding LabelField, but simply changing getPreferredHeight() to return getFont().getHeight()*N did not have the desired effect.

Thanks for your help!

Please use plain text.
Developer
adwiv
Posts: 304
Registered: ‎08-01-2008
My Device: Not Specified

Re: LabelField limited to N lines?

Use a fixed height rich text field.

 

Override the layout method like this:

 

protected void layout(int width, int height) { super.layout(width, height); setExtent(getWidth(), getFont().getHeight() * N); }

 

 

 

Please use plain text.
New Developer
jsdf
Posts: 32
Registered: ‎04-30-2009
My Device: Pearl 8120

Re: LabelField limited to N lines?

Ah, but this doesn't support the ellipses, correct?

I would like the Nth line to have the ellipses if the text continues onward.

Please use plain text.