Java/GWT/Grid
Grid Cell Formatter
package com.jexp.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.ruposite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollListener;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.RootPanel;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
Grid grid = new Grid(2, 4);
grid.setWidget(0, 0, new Label("0,0"));
grid.setWidget(0, 1, new Label("Grid"));
grid.setWidget(0, 2, new Label("0,2"));
grid.setWidget(0, 3, new Label("0,3"));
grid.setWidget(1, 0, new Label("1,0"));
grid.setWidget(1, 1, new Label("1,1"));
grid.setWidget(1, 2, new Label("1,2"));
grid.setWidget(1, 3, new Label("1,3"));
grid.setStyleName("panel grid");
for (int i = 0; i < grid.getRowCount(); i++) {
for (int j = 0; j < grid.getCellCount(i); j++) {
if ((j % 2) == 0) {
grid.getCellFormatter().setStyleName(i, j, "tableCell-even");
} else {
grid.getCellFormatter().setStyleName(i, j, "tableCell-odd");
}
}
}
RootPanel.get().add(grid);
}
}
///////////
.grid {
width: 150px;
height: 50px;
padding: 5px;
position: absolute;
left: 220px;
top: 350px;
}
.tableCell-even {
padding: 5px;
background: #008AB8;
border: 1px solid #ffffff;
}
.tableCell-odd {
padding: 5px;
background: #FFCC33;
border: 1px solid #ffffff;
}
.panel {
background-color: #C3D9FF;
border: 1px solid #000000;
padding: 3px;
margin: 3px;
font-weight: normal;
}
Grid control
package com.jexp.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Grid;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
Grid grid = new Grid(4, 4);
for (int r = 0; r < 4; ++r) {
for (int c = 0; c < 4; ++c) {
grid.setWidget(r, c, new HTML("A"));
}
}
RootPanel.get().add(grid);
}
}