1 | if (table.isEditing()) {↵ | | 1 | if (table.isEditing()) {↵
|
2 | TableCellEditor cellEditor = table.getCellEditor(table.getEditingRow(), table.getEditingColumn());↵ | | 2 | TableCellEditor cellEditor = table.getCellEditor(table.getEditingRow(), table.getEditingColumn());↵
|
3 | cellEditor.cancelCellEditing();↵ | | 3 | cellEditor.cancelCellEditing();↵
|
4 | }↵ | | |
|
|
5 | ↵ | | 4 | }↵
|
6 | int rowSelected = table.getSelectedRow();↵ | | 5 | int rowSelected = table.getSelectedRow();↵
|
7 | if (rowSelected >= 0) {↵ | | 6 | if (rowSelected >= 0) {↵
|
8 | tableModel.removeRow(rowSelected);↵ | | 7 | runCommandOnRow(command, rowSelected);↵
|
9 | tableModel.fireTableDataChanged();↵ | | 8 | tableModel.fireTableDataChanged();↵
|
|
10 | // Disable DELETE if there are no rows in the table to delete.↵ | | 9 | // Disable DELETE and BROWSE if there are no rows in the table to delete.↵
|
11 | if (tableModel.getRowCount() == 0) {↵ | | |
|
12 | delete.setEnabled(false);↵ | | |
|
13 | }↵ | | |
|
|
14 | ↵ | | 10 | checkDeleteAndBrowseStatus();↵
|
15 | // Table still contains one or more rows, so highlight (select)↵ | | 11 | // Table still contains one or more rows, so highlight (select)↵
|
16 | // the appropriate one.↵ | | 12 | // the appropriate one.↵
|
17 | else {↵ | | |
|
18 | ↵ | | 13 | if (tableModel.getRowCount() != 0) {↵
|
19 | int rowToSelect = rowSelected;↵ | | 14 | int rowToSelect = rowSelected;↵
|
|
20 | if (rowSelected >= tableModel.getRowCount()) {↵ | | 15 | if (rowSelected >= tableModel.getRowCount()) {↵
|
21 | rowToSelect = rowSelected - 1;↵ | | 16 | rowToSelect = rowSelected - 1;↵
|
22 | }↵ | | |
|
|
23 | ↵ | | 17 | }↵
|
24 | table.setRowSelectionInterval(rowToSelect, rowToSelect);↵ | | 18 | table.setRowSelectionInterval(rowToSelect, rowToSelect);↵
|
25 | }↵ | | |
|
26 | ↵ | | 19 | }↵
|
27 | } | | 20 | }
|