我遇到的问题是,当我选择一行时,具有自定义单元格渲染器的单元格不会突出显示该单元格,而是突出显示其他单元格。
public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
{
setFont(ApplicationStyles.TABLE_FONT);
if (value != null)
{
BigDecimal decimalValue = toBigDecimal(value);
decimalValue =
decimalValue.setScale(2, BigDecimal.ROUND_HALF_EVEN);
DecimalFormat formatter = new DecimalFormat("$##,##0.00");
formatter.setMinimumFractionDigits(2);
formatter.setMinimumFractionDigits(2);
String formattedValue = formatter.format(value);
setText(formattedValue);
}
return this;
}