UI: fixed row selecting in tables list

This commit is contained in:
Oleg Agafonov 2019-01-22 23:00:23 +04:00
parent 4349ec881e
commit dd09de7a09
3 changed files with 38 additions and 17 deletions

View file

@ -43,4 +43,21 @@ public class TablesUtil {
return row;
}
public static int getSelectedModelRow(JTable table) {
return getModelRowFromView(table, table.getSelectedRow());
}
public static int getModelRowFromView(JTable table, int viewRow) {
if (viewRow != -1 && viewRow < table.getModel().getRowCount()) {
return table.convertRowIndexToModel(viewRow);
}
return -1;
}
public static int getViewRowFromModel(JTable table, int modelRow) {
if (modelRow != -1 && modelRow < table.getModel().getRowCount()) {
return table.convertRowIndexToView(modelRow);
}
return -1;
}
}