07-15-2008 10:19 AM
Suppose you want a VFM that has a "margin" (white space left, right, top, & bottom), say 6 pixels.
What is the best way to accomplish this?
I have discovered the trick of creating a SeparatorField with a blank paint() method, to create some small amount of vertical spacing.
Solved! Go to Solution.
07-15-2008 10:28 AM
One way to accomplish this task might be to have a Manager within a Manager. In the outer Manager, override sublayout, and call layoutChild on the inner Manager, giving it a width and height that are screen width -12 and screen height -12. In the outer Manager, position the inner Manager at location 6, 6, and you should be in business.
07-22-2008 01:34 PM
In 4.6, there is a better way. Check out the new BorderFactory class in the decor package.
07-22-2008 01:57 PM
An easier way to do this is to use the setPadding() function:
VerticalFieldManager vfm = new VerticalFieldManager();
This will give you a margin of 10( top, right, bottom, left)
07-22-2008 02:45 PM - edited 07-22-2008 02:46 PM
07-22-2008 04:17 PM
AFAIK, it's *never* been visible, at least back to 4.2.0. It's still a public (and undocumented) method in 4.6.0. Still not a great idea to use undocumented features though, even if they work for the time being.
Most of my UI components derive from my own baseclass ("ActiveField" which derives from Field) so I can support things like tooltips, etc. In that class I have my own setPadding method which is used during layout. That way, if RIM ever takes it out (like Field.AXIS_SEQUENTIAL!) it won't break my code.
07-22-2008 09:12 PM
The only downside to this is that you then cannot use the existing classes, which means the code is larger. We try to avoid this to minimize the size of our final .cod. We also feel that this mechanism should be part of the underlying framework, and cannot understand why they would hide/deprecate such useful methods. Perhaps the new stuff pointed out above will fulfill the need, although require 4.5.
07-21-2009 02:33 PM
I've just been bitten by this in 4.5. I have some input fields that I wanted to align vertically using label fields for the variations in font. I used .setPadding because it was available in eclipse, not knowing it was 'hidden' and not available.
Now, when I've tried to move to a production build that is ant-only (no eclipse or RIM JDE), the compile fails because this method (setPadding) is not supported.
Yes, I know I could use other methods and other styles to get a similar (or same) effect. But this UI has gone all through dev / testing / UA and now the primary UI has to be redone.
I find it very frustrating that eclipse would suggest a method that isn't supported. boo.