ekjcfn3902039 ekjcfn3902039 - 1 year ago 131
Java Question

Changing the NatTable cell selection color

When I click on a row, the entire row color changes as expected. However the cell that the mouse is over changes to a different color than the rest of the row. I am trying to prevent the cell from changing to a color that is different from the rest of the row.

I am trying to figure out where the cell selection color is getting set and how to remove that (let the cell selection use the cells current background color).

I have unsuccessfully tried things like modifying the CellConfigAttribute or unregistering it via:


but no luck. I have no clue how to iterate over all the styles in order and see where this is generated from. I would have liked to see an existing method similar to:

List<ConfigAttribute<IStyle>> list = getNatTable().getConfigRegistry().

Unfortunately all I see is something like this, which I don't find useful for my situation:

List<String> strings = getNatTable().getConfigRegistry().

I have read the documentation which has some general advice but seen no explicit code samples showing how to do this. So, show do I determine where the cell is getting modified and how do I prevent it?

The code I am using for complete row selection is:

public void foo() {
final SelectionLayer selectionLayer = glazedListsGridLayer.
final RowOnlySelectionConfiguration<T> selectionConfig =
new RowOnlySelectionConfiguration<>();
getNatTable().addConfiguration(new RowOnlySelectionBindings());

Answer Source

You are talking about the selection anchor. And the only thing you have to do is to register the same style for DisplayMode.SELECT and label SelectionStyleLabels.SELECTION_ANCHOR_STYLE that you register for only DisplayMode.SELECT. The different style is registered in DefaultSelectionStyleConfiguration

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download