一只名叫tom的猫
你可以试试这个。我假设您熟悉表格单元格渲染器。您可以覆盖 getTableCellRendererComponent 方法并更改颜色,如下所示: public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // Get default renderer from the table TableCellRenderer renderer = table.getDefaultRenderer(table.getColumnClass(column)); Component comp = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value.equals("true") && row == 1 && col== 1){ comp.setBackground("YOUR COLOR"); }}