protected void deleteFile() { // If a table cell is being edited, we must cancel the editing before // deleting the row int rowSelected = files.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); } }
@Override public void actionPerformed(ActionEvent e) { int[] rows = table.getSelectedRows(); for(int i=0; i<rows.length; i++){ model.removeRow(rows[i]-i); } if(model.getRowCount()>1) { upButton.setEnabled(true); downButton.setEnabled(true); } else { upButton.setEnabled(false); downButton.setEnabled(false); } } }
/** * runs specified command on currently selected table row. * * @param command specifies which process will be done on selected * file. it's coming from action command currently caught by * action listener. * * @param rowSelected index of selected row. */ private void runCommandOnRow(String command, int rowSelected) { if (DELETE.equals(command)) { tableModel.removeRow(rowSelected); } else if (BROWSE.equals(command)) { String path = browseAndGetFilePath(); if(StringUtils.isNotBlank(path)) { tableModel.setValueAt(path, rowSelected, 0); } } }
/** * Remove the currently selected argument from the table. */ private void deleteArgument() { // If a table cell is being edited, we must cancel the editing before // deleting the row GuiUtils.cancelEditing(table); int rowSelected = table.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); // Disable DELETE if there are no rows in the table to delete. if (tableModel.getRowCount() == 0) { delete.setEnabled(false); } // Table still contains one or more rows, so highlight (select) // the appropriate one. else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } table.setRowSelectionInterval(rowToSelect, rowToSelect); } } }
/** * Remove the currently selected argument from the table. */ protected void deleteArgument() { GuiUtils.cancelEditing(table); int[] rowsSelected = table.getSelectedRows(); int anchorSelection = table.getSelectionModel().getAnchorSelectionIndex(); table.clearSelection(); if (rowsSelected.length > 0) { for (int i = rowsSelected.length - 1; i >= 0; i--) { tableModel.removeRow(rowsSelected[i]); } // Table still contains one or more rows, so highlight (select) // the appropriate one. if (tableModel.getRowCount() > 0) { if (anchorSelection >= tableModel.getRowCount()) { anchorSelection = tableModel.getRowCount() - 1; } table.setRowSelectionInterval(anchorSelection, anchorSelection); } checkButtonsStatus(); } }