-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Please..
I want to create a grid by java code but I did not find some example to do it.
I want to insert components programmatically, but I had tried creating a row and tried to add it to the grid, but it did not work.
I tried to use getRows().appendChild, but I got null pointer exception.
Well, unfortunelly I could not figure out how can I do it.
Any ideas ?
Thanks
Hi,
the following sample should give you the idea:
Grid grid = new Grid(); grid.appendChild(new Rows()); Row row = new Row(); row.appendChild(new Label("Your Name")); row.appendChild(new Textbox()); grid.getRows().appendChild(row);
Cheers, Maik
hai,
you can see my code.
private void setDisplayGrid(){ Grid mygrid = (Grid)getComponent("itemlist"); String[][] rowgrid = new String[2][2]; ListModel strset = null; rowgrid[0][0]= "a"; rowgrid[1][0]= "b"; strset = new SimpleListModel(rowgrid); if (strset != null){ mygrid.setModel(strset); mygrid.setRowRenderer(new rowRenderLstItem()); } } class rowRenderLstItem implements RowRenderer{ public void render(Row row, java.lang.Object data) throws Exception { new Textbox("aaa").setParent(row); new Textbox("bbb").setParent(row); } }
Regards,
Andy Susanto
Hello,
you can try button-up method instead top-down like ibsolusion said.
Example :
Label label = new Label(); Textbox textbox = new Textbox(); Row row = new Row(); Rows rows = new Rows(); label.setParent(row); textbox.setParent(row); row.setParent(rows);
Thanks
Asked: 2008-12-20 22:04:32 +0800
Seen: 646 times
Last updated: Dec 22 '08