I have two events that support the button and table by click mouse if i click te button should remove the record from the list and table. It happens but program display this exception ArrayIndexOutOfBoundsException: -1
r.getjTable3().addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent e)
{
System.out.println(e.getClickCount());
r.getjButton2().addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent e)
{
String nazwa = r.getjTable3().getValueAt(r.getjTable3().getSelectedRow(), 3).toString();
System.out.println(r.getjTable3().getSelectedRow());
((DefaultTableModel)r.getjTable3().getModel()).removeRow(r.getjTable3().getSelectedRow());
for (Wydarzenie lista1 : lista)
{
if(nazwa==lista1.name)
{
lista.remove(lista1);
}
}
}
});
}
});