How can I use these labels using a loop, instead of creating 40 lines of code repeated?
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")));