Why do you think your code should put the cubes in a row/column? They all have the same coordinates, sizes, transforms and belong to the same transform group... You have to create a new transform and transform group for each box you want placed separately.
Something like this should do the trick for 4 boxes:
TransformGroup getNewBox(float hpos) {
Cuboid box = new Cuboid(0.03f, 0.03f, 0.03f, cubeAppearance);
TransformGroup tg = new TransformGroup();
Transform3D transform = new Transform3D();
Vector3f vector = new Vector3f(0f, hposf, 0f);
transform.setTranslation(vector);
tg.addChild(box);
tg.setTransform(transform);
return tg;
}
{
rootGroup.addChild(getNewBox(0f);
rootGroup.addChild(getNewBox(0.3f);
rootGroup.addChild(getNewBox(0.6f);
rootGroup.addChild(getNewBox(0.9f);
}