Skip to content

Commit

Permalink
Fix potential exception when removing custom properties
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-wilke committed Apr 8, 2020
1 parent 24cd048 commit 3af2988
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion utiliti/src/de/gurkenlabs/utiliti/swing/panels/CustomPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,29 @@ public CustomPanel() {
this.scrollPane = new JScrollPane();

JButton buttonAdd = new JButton("+");
buttonAdd.addActionListener(a -> model.addRow(new Object[] { "", "" }));
buttonAdd.addActionListener(a -> {
TableCellEditor editor = tableCustomProperties.getCellEditor();
if (editor != null) {
editor.stopCellEditing();
}
model.addRow(new Object[] { "", "" });
model.fireTableDataChanged();
});

JButton buttonRemove = new JButton("-");
buttonRemove.addActionListener(a -> {
TableCellEditor editor = tableCustomProperties.getCellEditor();
if (editor != null) {
editor.stopCellEditing();
}

int[] rows = tableCustomProperties.getSelectedRows();
for (int i = 0; i < rows.length; i++) {
model.removeRow(rows[i] - i);
}

model.fireTableDataChanged();
tableCustomProperties.revalidate();
});

GroupLayout groupLayout = new GroupLayout(this);
Expand Down

0 comments on commit 3af2988

Please sign in to comment.