I have done a lot of reading here and used a lot of examples posted but I still can't get this to work. Note that I'm a newbie!
I want a simple grid on my main screen with 4 rows and 4 columns. The first column should be a little wider than the other 3 since it contains a checkboxfield; the remaining 3 columns contain editfields. Would be nice to separate each column by a space but at this point I don't care if they're all stuck together. My aim is to have the 3 editfields lined up vertically on the right side of the screen. It would look like this:
My thought-process is to use horizontalfieldmanager and verticalfieldmanager. But when I do this none of the fields line up. They always seem to be placed horizontally one after the other. The checkbox fields on each row are not all the same width so the editbox fields will not align.
I thought that adding 4 vfm's to a hfm would result in evenly spaced columns afterwhich adding the fields would line up. But it seems that the width is determined by the field being added.
Here's a snippet of my code so far:
HorizontalFieldManager hfm1 = new HorizontalFieldManager();
VerticalFieldManager vfm11 = new VerticalFieldManager();
VerticalFieldManager vfm12 = new VerticalFieldManager();
VerticalFieldManager vfm13 = new VerticalFieldManager();
VerticalFieldManager vfm14 = new VerticalFieldManager();
vfm11.add(new CheckboxField("Name", true)); // first column
vfm12.add(new FixedWidthField("", "text1")); // second column
vfm13.add(new FixedWidthField("", "text2")); // third column
vfm14.add(new FixedWidthField("", "text3")); // fourth column
//Repeat the above for each additional row
//My custom field; required because I want to limit the width & I plan
public class FixedWidthField extends EditField
public FixedWidthField(String c, String d)
public int getPreferredWidth()
public void layout(int maxWidth, int maxHeight)
I suspect I need a custom vfm. Is that the only way to set the columns to a fixed width? Can anyone provide a short example of a custom vertical field manager or point me to one?