How to create a grid in Java code ?
20 Dec 2008 22:04:32 GMT
20 Dec 2008 22:25:37 GMT
20 Dec 2008 22:25:37 GMT
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
21 Dec 2008 00:46:52 GMT
21 Dec 2008 00:46:52 GMT
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
21 Dec 2008 15:54:44 GMT
21 Dec 2008 15:54:44 GMT
Oh !!
Great .. it helps a lot
Thank you guys
22 Dec 2008 04:09:58 GMT
22 Dec 2008 04:09:58 GMT
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
ZK - Open Source Ajax Java Framework
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