fixed a ClassCastException-bug while removing a panel