Prevent AIOOBE in error table

If the error checker updates the table between the click and invocation
of the click event listener, selection will be cleared and click index
will be -1. Checking if the index is valid before using it.
This commit is contained in:
Jakub Valtar
2015-09-26 10:11:11 -04:00
parent 15d14375ca
commit 5ab6cd5fc4
+18 -18
View File
@@ -105,25 +105,25 @@ public class ErrorTable extends JTable {
// }
addMouseListener(new MouseAdapter() {
@Override
synchronized public void mouseClicked(MouseEvent e) {
try {
int row = ((ErrorTable) e.getSource()).getSelectedRow();
if (row >= 0 && row < getRowCount()) {
Object data = getModel().getValueAt(row, DATA_COLUMN);
int clickCount = e.getClickCount();
if (clickCount == 1) {
editor.errorTableClick(data);
} else if (clickCount > 1) {
editor.errorTableDoubleClick(data);
}
@Override
synchronized public void mouseClicked(MouseEvent e) {
try {
int row = ((ErrorTable) e.getSource()).getSelectedRow();
if (row >= 0 && row < getRowCount()) {
Object data = getModel().getValueAt(row, DATA_COLUMN);
int clickCount = e.getClickCount();
if (clickCount == 1) {
editor.errorTableClick(data);
} else if (clickCount > 1) {
editor.errorTableDoubleClick(data);
}
// editor.getErrorChecker().scrollToErrorLine(row);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
/*
addMouseMotionListener(new MouseMotionAdapter() {