Is it possible to determine the path of a chosen image with a variable? like this:
private JLabel label = new JLabel();
int number = 1;
label.setIcon(new ImageIcon(getClass().getResource("/image" + number + ".png")));
In this case it does not work, but my idea might be clear. In this case I could just simply change the variable name in order to change the path of my image. Does anybody know how to do so?
Aucun commentaire:
Enregistrer un commentaire