Interface GridCellRenderer
- All Known Implementing Classes:
DefaultGridCellRenderer
public interface GridCellRenderer
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;
}
});
-
Method Summary
Modifier and TypeMethodDescriptionintgetPreferredWidth(GridCell cell) The width, in pixels, the cell's content needs, for a column that sizes itself to what it shows.voidPaints a cell into the rectanglex,y,width,height.
-
Method Details
-
paint
-
getPreferredWidth
The width, in pixels, the cell's content needs, for a column that sizes itself to what it shows.
-