@Test public void testActionPerformed() { System.out.println("actionPerformed"); ActionEvent e = null; DeleteRowAction instance = new DeleteRowAction(new JPanel(), new JTable(), new PowerTableModel(TableModelEmul.columnIdentifiers, TableModelEmul.columnClasses), new JButton()); instance.actionPerformed(e); }
public void actionPerformed(ActionEvent e) { if (grid.isEditing()) { TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn()); cellEditor.cancelCellEditing(); } int rowSelected = grid.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); if (tableModel.getRowCount() == 0) { deleteRowButton.setEnabled(false); } else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } grid.setRowSelectionInterval(rowToSelect, rowToSelect); } sender.updateUI(); } }
DeleteRowAction implements ActionListener { public void actionPerformed(ActionEvent e) { if (grid.isEditing()) { TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn()); cellEditor.cancelCellEditing(); } int rowSelected = grid.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); if (tableModel.getRowCount() == 0) { deleteRowButton.setEnabled(false); } else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } grid.setRowSelectionInterval(rowToSelect, rowToSelect); } sender.updateUI(); } } }
DeleteRowAction implements ActionListener { public void actionPerformed(ActionEvent e) { if (grid.isEditing()) { TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn()); cellEditor.cancelCellEditing(); } int rowSelected = grid.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); if (tableModel.getRowCount() == 0) { deleteRowButton.setEnabled(false); } else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } grid.setRowSelectionInterval(rowToSelect, rowToSelect); } sender.updateUI(); } } DeleteRowAction(JComponent aSender, JTable grid, PowerTableModel tableModel, JButton deleteRowButton); }
DeleteRowAction implements ActionListener { public void actionPerformed(ActionEvent e) { if (grid.isEditing()) { TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn()); cellEditor.cancelCellEditing(); } int rowSelected = grid.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); if (tableModel.getRowCount() == 0) { deleteRowButton.setEnabled(false); } else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } grid.setRowSelectionInterval(rowToSelect, rowToSelect); } sender.updateUI(); } } DeleteRowAction(JComponent aSender, JTable grid, PowerTableModel tableModel, JButton deleteRowButton); void actionPerformed(ActionEvent e); }
DeleteRowAction implements ActionListener { public void actionPerformed(ActionEvent e) { if (grid.isEditing()) { TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn()); cellEditor.cancelCellEditing(); } int rowSelected = grid.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); if (tableModel.getRowCount() == 0) { deleteRowButton.setEnabled(false); } else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } grid.setRowSelectionInterval(rowToSelect, rowToSelect); } sender.updateUI(); } } DeleteRowAction(JComponent aSender, JTable grid, PowerTableModel tableModel, JButton deleteRowButton); void actionPerformed(ActionEvent e);  }