1
How can I use these Abels using a loop instead of creating 40 lines of repeated code?
jLabel1.setIcon(new ImageIcon(getClass().getResource("/cards/"+cards.get(1)+".png")));
jLabel2.setIcon(new ImageIcon(getClass().getResource("/cards/"+cards.get(1)+".png")));
jLabel3.setIcon(new ImageIcon(getClass().getResource("/cards/"+cards.get(2)+".png")));
jLabel4.setIcon(new ImageIcon(getClass().getResource("/cards/"+cards.get(3)+".png")));
why in English? (mistake?)
– jsantos1991
@Earendul The question was in English and I translated, I just forgot to comment here, sorry. Maybe his difficulty is in catching the object
jLabel + i
, but since I don’t know java I can’t opine on that...– Jader A. Wagner
I think it was a CTRL+C, CTRL+V kind of rushed. Look: Loop using jLabels in swing.
– Math
no, first I put it here, then I saw it was in the Portuguese section. the control+C went from here to here. First day, first post....
– Rodrigo Cipriano