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