I need to print a list of teams in a JLabel
, so I'd like to order each of them in a different lane but when I try my code it seems like the "\n" part if the code doesn't work. I've been reading a bit and many solutions show that it needs to be inside HTML tags. I've tried and no solutions I got.
private void terminarEquiposActionPerformed(java.awt.event.ActionEvent evt) {
if(listadoEquipos.size() < numEquipos){
this.aviso.setText("Faltan " + (numEquipos-listadoEquipos.size()) + " equipos.");
}else{
this.jDialogEquipos.setVisible(false);
this.jPanel1.setVisible(true);
String lista = "";
for(int i = 0; i < listadoEquipos.size(); i++){
lista += (i+1) + " : " + listadoEquipos.get(i).getNombre() + '\n'; //TODO saltos de linea en jLabel
}
this.imagenUEFA.setText(lista);
contador = 0;
}
}
The ArrayList
listadoEquipo
contains the names I need to show and I use the String
lista
for building the result I want to show in the label imagenUEFA
.
I'm not allowed to share png yet but when I run I got this:
At the left of the picture there's the label to show the name of the teams and the rest of picture are buttons for the activity

`) would suit this well. 3) *"..inside html tags. I've tried and no solutions I got."* Well, apparently the HTML used was .. incorrect. See point (1).
– Andrew Thompson Jan 08 '22 at 16:20