Note that for all Renderers (with the exception of the prepared Renderer) you must / be sure that you need to call this after changing any column / row in JTable
TableColumnModel m = myTable.getColumnModel(); m.getColumn(5).setCellRenderer(new SubstDateRenderer());
here you can set BackGround, ForeGround for TableCell
import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.table.DefaultTableCellRenderer; public class SubstDateRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; private Date dateValue; private SimpleDateFormat sdfNewValue = new SimpleDateFormat("dd.MMMM.yyyy"); private String sdfNewValueString = ""; public SubstDateRenderer() {
source share