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
Regular Contributor
Posts: 71
Registered: ‎03-18-2009
My Device: Not Specified

How would you know if a LabelField was forced to wrap during the layout process?

I have a fixed size vertical manager, that prevents fields to become too wide. It works fine, but after sublayout() I would like to inspect the fields to see if any wrapped around because the set width of my manager was too small. As can be seen in my picture, the LabelField wrapped around. I would like to know how do I know programmically if the LabelField wrapped around?

 

public class FixedSizeVerticalManager extends VerticalFieldManager {

 private int width;
 
 public FixedSizeVerticalManager(int width) {
  super(0);
  this.width = width;
 }

 protected void sublayout(int width, int height) {
  width = this.width;
  super.sublayout(width, height);
 }
}

Untitled.png

Developer
Posts: 16,998
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How would you know if a LabelField was forced to wrap during the layout process?

 

just some ideas:

- check the field height against the font height

- overwrite drawText, do some checks and call super.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 71
Registered: ‎03-18-2009
My Device: Not Specified

Re: How would you know if a LabelField was forced to wrap during the layout process?

Yeah I used the font.getadvance for that. thought there was a nicer way, but thanks anyway. always good to have it confirmed