ekjcfn3902039 ekjcfn3902039 - 1 year ago 127
Java Question

Does NatTable need a manual refresh after repaintCell?

I have the following code snippet.

int index = getEventList().indexOf(myObj);
SelectionLayer selectionLayer = getGlazedListsGridLayer()

When I run the code shown above, the affected cells only get repainted after I click on the table displayed in the GUI. If I comment out that code and use
it repaints without me having to first click on the table.

Is there a way to have a cell repainted without having to click on the table displayed in the GUI? I would hate to have to call refresh() for a large table where this code may be executed many times.

Answer Source

No you don't need to perform some additional step in order to trigger the repainting. The issue in your code is the usage of wrong index values. You have a grid so column 0 is the row header from the NatTable perspective. I suppose you want to redraw the first column of the body, which is index 1 from the NatTable point of view. Also the row index is incorrect, as you calculate the index in the SelectionLayer but actually need the index in the table, which is at minimum +1 if you only have a column header row.

Actually your code should work by adding 1 on the index if you have one row header column and one column header row in the grid.

getNatTable().repaintCell(1, selectionLayer.getRowIndexByPosition(index) + 1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download