EDIT
I want to print the 11 players that the user types in the interface.
Player is an object with the data string dorsal, last name and position.
Gamer is where the whole interface you see below is.
Driver is listener where I add function to the show and add button
t1, t2, t3, t4 are the JTextfield
Player1 is the name of the Player type arraylist
No matter how the players are saved, I just need to know that so there is no problem in changing the code.
I enclose the code where I am filling everything.
public void actionPerformed(ActionEvent eve)
{
try{
if (eve.getActionCommand().contentEquals("Agregar"))
{
String dorsal= this.verEquipo.t1.getText();
String nombre= this.verEquipo.t2.getText();
String apellido= this.verEquipo.t3.getText();
String posicion= this.verEquipo.t4.getText();
jugador.setDorsal(dorsal);
jugador.setNombre(nombre);
jugador.setApellido(apellido);
jugador.setPosicion(posicion);
jugador1.add(jugador);
}
else if (eve.getActionCommand().contentEquals("Mostrar"))
{
imprimir();
}
}
catch (Exception e){ e.printStackTrace();}
}
public void imprimir(){
Integer size=jugador1.size();
for(int i=0;i<jugador1.size();i++){
System.out.println(jugador1.get(i).getDorsal());
System.out.println(jugador1.get(i).getNombre());
System.out.println(jugador1.get(i).getApellido());
System.out.println(jugador1.get(i).getPosicion());
}
}