Changing cell Color is resetting cell default...
Hi, I've a JTable and one of the Columns is defined as double, the data inside the cells of that column is aligned Right automatically. When I change the cell color to "red" if the value is less than certain value, then all cells are left aligned!! How can I keep the default settings of the column as it is even after changing the color of the cells? this is the methods I got from some websites on Internet.... public static void setCellRenderer(JTable CustDtlsTbl) { TableCellRenderer cellRenderer = createCellRenderer(); CustDtlsTbl.setDefaultRenderer(Object.class, cellRenderer); } public static TableCellRenderer createCellRenderer() { return new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable CustDtlsTbl, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(CustDtlsTbl, value, isSelected, hasFocus, row, column); if ( column == 3 ){ double newValue = Double.parseDouble(value.toString()); if ( newValue < 100 ){ cell.setForeground(Color.RED); } } else { cell.setForeground(Color.BLACK); } return cell; } }; } Thanks