Ejemplo: jtable establece el color de fondo de la columna
table.getColumn("Column title").setCellRenderer(
new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int col) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
Float quantityRemaining = (Float) table.getModel().getValueAt(row, col);
if (quantityRemaining < 1) {
setBackground(table.getBackground());
setForeground(Color.RED);
setToolTipText("This item needs immediate restocking!!!");
} else {
setBackground(table.getBackground());
setForeground(table.getForeground());
setToolTipText("Resonable stock quantities");
}
return table;
}
});
}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)