How to change jtable cell Background Dynamically
问题 I am having a JTable table1 with 5 rows and 5 columns, and I would like to change the background color of 3rd column/cell of 2nd row, when I call a function like changeBgColor(row,col); Is this possible? 回答1: Override prepareRenderer method for doing that. Example: public Component prepareRenderer (TableCellRenderer renderer, int rowIndex, int columnIndex){ Component componenet = super.prepareRenderer(renderer, rowIndex, columnIndex); if(rowIndex % 2 == 0) { componenet.setBackground(Color.RED