Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public interface GridCellRenderer
Known subtypesDefaultGridCellRenderer
Paints the cells of a DataGrid column.
A renderer draws straight into the grid’s graphics. There is no
component per cell, which is what lets a grid show a million rows: only
the cells on screen are painted, and each costs what its drawing costs.
The row’s background is already painted when paint is called.
DataGrid grid = new DataGrid(new DefaultTableModel(new String[]{"Item", "Balance"},
new Object[][]{{"rent", -1200}, {"salary", 4000}}, false));
grid.getColumn(1).setRenderer(new DefaultGridCellRenderer() {
protected int textColor(GridCell cell, int defaultColor) {
Object v = cell.getValue();
return v instanceof Number && ((Number) v).doubleValue() < 0 ? 0xc62828 : defaultColor;
}
});Methods
public abstract void paint(Graphics g, GridCell cell, int x, int y, int width, int height) | Paints a cell into the rectangle x, y, width, height. |
public abstract int getPreferredWidth(GridCell cell) | The width, in pixels, the cell’s content needs, for a column that sizes itself to what it shows. |
Method details
paint
public abstract void paint(Graphics g, GridCell cell, int x, int y, int width, int height)Paints a cell into the rectangle
x, y, width, height. The
graphics is clipped to it.getPreferredWidth
public abstract int getPreferredWidth(GridCell cell)The width, in pixels, the cell’s content needs, for a column that
sizes itself to what it shows.