我对在 NatTable 单元格中使用图像有疑问。我的 ConfigLabelAccumulator 和 Configuration 看起来像这样
public class MyConfigLabelAccumulator implements IConfigLabelAccumulator {
@Override
public void accumulateConfigLabels(final LabelStack configLabels, final int columnPosition, final int rowPosition) {
if (((rowPosition + columnPosition) % 2) == 0) {
configLabels.addLabel("myLabel");
}
}
}
public class MyStyleConfiguration extends DefaultNatTableStyleConfiguration {
@Override
public void configureRegistry(final IConfigRegistry configRegistry) {
super.configureRegistry(configRegistry);
final Style style = new Style();
style.setAttributeValue(CellStyleAttributes.IMAGE, GUIHelper.getImage("plus"));
style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_YELLOW);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, "myLabel");
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.RIGHT, new ImagePainter()), DisplayMode.NORMAL);
}
}
我这样配置
dataLayer.setConfigLabelAccumulator(new MyConfigLabelAccumulator());
...
natTable.addConfiguration(new MyStyleConfiguration());
...
natTable.configure();
表看起来像预期的那样。我在单元格中看到黄色背景单元格和“+”图像。但打电话后
natTable.setTheme(new ModernNatTableThemeConfiguration());
我只看到黄色背景,没有图像。
UPD:
我已经解决了这个问题,IThemeExtension
但可能还有另一种解决方案吗?