From f3f5292eb08ea9b5cccabbfae9d0536245174e8f Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Mon, 30 Dec 2024 15:35:36 -0300 Subject: [PATCH] '#2391: Force the repaint of gallery single selected item. --- .../main/java/iped/app/ui/GalleryTable.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/iped-app/src/main/java/iped/app/ui/GalleryTable.java b/iped-app/src/main/java/iped/app/ui/GalleryTable.java index 8b09b0f018..5adef8abdc 100644 --- a/iped-app/src/main/java/iped/app/ui/GalleryTable.java +++ b/iped-app/src/main/java/iped/app/ui/GalleryTable.java @@ -11,6 +11,7 @@ import javax.swing.JTable; import javax.swing.KeyStroke; import javax.swing.UIManager; +import javax.swing.table.TableCellEditor; import javax.swing.table.TableModel; public class GalleryTable extends JTable { @@ -79,6 +80,25 @@ public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boole super.changeSelection(rowIndex, columnIndex, toggle, extend); } + @Override + public void repaint() { + // Before calling the actual repaint(), force the repaint of current selected + // cell. If a single cell is selected, sometimes its content is not refreshed + // after calling the regular repaint(); + // See issue #2391. + if (getModel() != null && getSelectionModel() != null) { + int col = getSelectedColumn(); + int row = getSelectedRow(); + if (row >= 0 && col >= 0) { + TableCellEditor editor = getCellEditor(row, col); + if (editor != null) { + editor.stopCellEditing(); + } + } + } + super.repaint(); + } + public int getLeadSelectionIndex() { if (selectedCells.get(lead)) { return lead;