Java - Remove no funciona

 
Vista:

Remove no funciona

Publicado por remove no funciona (35 intervenciones) el 17/03/2021 00:24:15
Hola buenas noches. Tengo un problema para eliminar elementos de un arraylist.
Cuando llamo al metodo remove no funciona. No borra el elemento deseado.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
boton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        try {
            if (indice < miControl.jugador(nombreJ).cartasEnMano.size()) {
                r=indice;
            ImageIcon imagen = new
                     ImageIcon(miControl.jugador(nombreJ).cartasEnMano.get(indice)+".jpg");
            cartaNum.setText("Carta numero: "+ indice);
            btn.setIcon(new
ImageIcon(imagen.getImage().getScaledInstance(btn.getWidth(),btn.getHeight(),Image.SCALE_SMOOTH)));
            indice++;
 
            }else {
                indice=0;
                r=0;
 
            }
 
            }
 
 
         catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
    }
});
 
boton3.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    try {
 
        miControl.tirarCarta(r,miControl.jugador(nombreJ));
        indice=0;
        r=0;
        }
 
        else {
 
        }
    }
 
 
 
public void tirarCarta( int op, Jugador j) throws RemoteException {
      //op va a ser la carta a tirar y jugador va a ser el jugador que la tira
    mesa.add(j.cartasEnMano.get(op));
    j.cartasEnMano.remove(j.cartasEnMano.get(op));
 
 
}


Si alguien me puede ayudar se lo agradeceria



1
2
3
4
catch (RemoteException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder