在@DirkFauth 的回答之后,我有这个工作。这个答案包括一些细节。
表配置好NatTable.configure()后,你可以不用NatTable.addConfiguration(IConfiguration)修改配置,而是调用IConfiguration.configureRegistry(IConfigRegistry)。例如:
myConfiguration.configureRegistry( myTable.getConfigRegistry() )
在 configureRegistry() 的实现中,您可以设置选定单元格和锚定单元格的样式:
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
selectedStyle, DisplayMode.SELECT, GridRegion.BODY);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
anchorStyle, DisplayMode.SELECT,
SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
当表处于非活动状态时,selectedStyle 和 anchorStyle 可以修改为它们通常设置的克隆。例如:
private static Color myInactiveColor = ...;
public static Style makeInactiveBodyCellStyleFrom(@Nonnull Style style) {
Style rv = style.clone();
rv.setAttributeValue( CellStyleAttributes.BACKGROUND_COLOR,
myInactiveColor );
return rv;
}
可以对选定的行和列标题的样式进行类似的工作。