gpt4 book ai didi

java - NatTable - CheckBoxCellEditor 和 CheckBoxPainter 在单击时显示文本

转载 作者:行者123 更新时间:2023-12-02 13:18:33 24 4
gpt4 key购买 nike

我正在使用 CheckBoxCellEditor 和 CheckBoxPainter 在 NatTable 中显示 boolean 属性,如下所示

enter image description here

问题:使用鼠标单击单元格时,它会将 boolean 值显示为文本,如下所示,而不是将状态重置为 false。

enter image description here

下面是我的代码片段,

//register the column
ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
bodyLayer.getBodyDataLayer());
bodyLayer.getBodyDataLayer().setConfigLabelAccumulator(columnLabelAccumulator);
columnLabelAccumulator.registerColumnOverrides(0, COLUMN_BOOKMARK_LABEL);

//added the CheckBoxCellEditor and CheckBoxCellPainter to configuration.
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new CheckBoxCellEditor(), DisplayMode.NORMAL,
COLUMN_BOOKMARK_LABEL);

configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CheckBoxPainter(ImageUtil.getImage("Images.BookmarkChecked"),
ImageUtil.getImage("Images.BookmarkUnchecked")),
DisplayMode.NORMAL, COLUMN_BOOKMARK_LABEL);

configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, COLUMN_BOOKMARK_LABEL);
}
});

我还让 rowselectionProvider 将默认选择设置为第一行,并根据行选择刷新属性 UI。

关于缺少链接的任何指示。TIA

最佳答案

看起来有一个为 DisplayMode.SELECT 注册的画家,它取代了在 DisplayMode.NORMAL 中为您的标签注册的画家。添加这一行应该可以解决您的问题

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
new CheckBoxPainter(
ImageUtil.getImage("Images.BookmarkChecked"),
ImageUtil.getImage("Images.BookmarkUnchecked")),
DisplayMode.SELECT,
COLUMN_BOOKMARK_LABEL);

我不确定您的其余样式配置。通常,配置是分层的。因此需要详细检查为什么使用另一画家而不是正常模式的画家。

关于java - NatTable - CheckBoxCellEditor 和 CheckBoxPainter 在单击时显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43670102/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com