Form form = (Form)this.getForm();
GridLayout gl = new GridLayout();
gl.setId("myGrid");
gl.setCellSpacing(5);
gl.setWidth("40%");
gl.setDebugMode(true);
Button button = new Button("button", "button");
GridLayoutCell cell11 = new GridLayoutCell("cell11");
cell11.setHAlignment(CellHAlign.RIGHT);
cell11.setWidth("10%");
cell11.setContent(button);
gl.addCell(1, 1, cell11);
TextView tv1 = new TextView("tv1");
tv1.setText("Celltext aligned left");
GridLayoutCell cell12 = new GridLayoutCell("cell12");
cell12.setHAlignment(CellHAlign.LEFT);
cell12.setWidth("40%");
cell12.setContent(tv1);
gl.addCell(1, 2, cell12);
Button button2 = new Button("button2", "button");
GridLayoutCell cell21 = new GridLayoutCell("cell21");
cell21.setHAlignment(CellHAlign.LEFT);
cell21.setWidth("10%");
cell21.setContent(button2);
gl.addCell(2, 1, cell21);
TextView tv2 = new TextView("tv2");
tv2.setText("Celltext aligned right");
GridLayoutCell cell22 = new GridLayoutCell("cell22");
cell22.setHAlignment(CellHAlign.RIGHT);
cell22.setWidth("40%");
cell22.setContent(tv2);
gl.addCell(2, 2, cell22);
form.addComponent(gl);