* Fixed ArrayIndexOutOfBoundsException by trying to do actions on tables removed meanwhile.

This commit is contained in:
LevelX2 2016-01-15 21:03:39 +01:00
parent acb57c0fc8
commit cdbda6a7e6

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.util;
import java.awt.Component;
@ -78,18 +77,13 @@ public class ButtonColumn extends AbstractCellEditor implements TableCellRendere
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (hasFocus)
{
if (hasFocus) {
renderButton.setForeground(table.getForeground());
renderButton.setBackground(UIManager.getColor("Button.background"));
}
else if (isSelected)
{
} else if (isSelected) {
renderButton.setForeground(table.getSelectionForeground());
renderButton.setBackground(table.getSelectionBackground());
}
else
{
} else {
renderButton.setForeground(table.getForeground());
renderButton.setBackground(UIManager.getColor("Button.background"));
}
@ -107,35 +101,40 @@ public class ButtonColumn extends AbstractCellEditor implements TableCellRendere
@Override
public void actionPerformed(ActionEvent e) {
if (table.getRowCount() >= table.getEditingRow()) {
int row = table.convertRowIndexToModel(table.getEditingRow());
fireEditingStopped();
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row);
action.actionPerformed(event);
}
}
@Override
public void mousePressed(MouseEvent arg0) {
if (table.isEditing() && table.getCellEditor() == this)
if (table.isEditing() && table.getCellEditor() == this) {
isButtonColumnEditor = true;
}
}
@Override
public void mouseReleased(MouseEvent arg0) {
if (isButtonColumnEditor && table.isEditing())
if (isButtonColumnEditor && table.isEditing()) {
table.getCellEditor().stopCellEditing();
}
isButtonColumnEditor = false;
}
@Override
public void mouseClicked(MouseEvent arg0) {}
public void mouseClicked(MouseEvent arg0) {
}
@Override
public void mouseEntered(MouseEvent arg0) {}
public void mouseEntered(MouseEvent arg0) {
}
@Override
public void mouseExited(MouseEvent arg0) {}
public void mouseExited(MouseEvent arg0) {
}
}