Reputation:
By default it has an image with the path /img/profileicon/29.png
but then from the main I want to change it, but for some reason instead of changing it disappears.
The code:
int iconId = summoner.getProfileIconId();
ImageIcon img = new javax.swing.ImageIcon("/img/profileicon/"+iconId+".png");
profileIconImg.setIcon(img);
Upvotes: 2
Views: 87
Reputation:
Finally I was able to use this code, making use of class.getResource
URL iconUrl = EuwGG.class.getResource("/img/profileicon/"+profileIconId+".png");
Image profileImage = ImageIO.read(iconUrl);
ImageIcon profileIcon = new ImageIcon(profileImage);
Image i = profileIcon.getImage().getScaledInstance(125, 125, Image.SCALE_SMOOTH);
profileIcon = new ImageIcon(i);
profileIconImg.setIcon(profileIcon);
Upvotes: 1