I hoping that you created folder with name Images
there are lots of ways:
button.setIcon(new ImageIcon(this.getClass().getClassLoader().getResource("Images/iconName")));
but I still prefered
Image ViewFxImage = ImageViewFxLoader.getImage(ViewFxDeals.class, "resources/passed.png");
final Icon ViewFxIcon = new ImageIcon(ViewFxImage);
myButton.setIcon(null); //remove Icon
myButton.setIcon(ViewFxIcon); //add Icon
class ImageViewFxLoader {
private ImageViewFxLoader() {
}
public static Image getImage(Class<?> relativeClass, String filename) {
Image returnValue = null;
InputStream is = relativeClass.getResourceAsStream(filename);
if (is != null) {
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
int ch;
while ((ch = bis.read()) != -1) {
baos.write(ch);
}
returnValue = Toolkit.getDefaultToolkit().createImage(baos.toByteArray());
} catch (IOException exception) {
SaveEventToDb.errorWritter();
} finally {
try {
bis.close();
baos.close();
bis = null;
baos = null;
} catch (IOException ex) {
Logger.getLogger(ImageViewMmLoader.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
return returnValue;
}
}
resolutions in 16x16 or 32x32 in pixels
mKorbel
Nearly a Posting Virtuoso
1,215 posts since Feb 2011
Reputation Points: 482
Solved Threads: 239
Skill Endorsements: 12
mKorbel
Nearly a Posting Virtuoso
1,215 posts since Feb 2011
Reputation Points: 482
Solved Threads: 239
Skill Endorsements: 12
hmmm aaaaaaaand what packages name contains yor Main Class
something like as ...
myPackage
- Main
myPackage/Images
- xxx.png
--yyy.png
mKorbel
Nearly a Posting Virtuoso
1,215 posts since Feb 2011
Reputation Points: 482
Solved Threads: 239
Skill Endorsements: 12
mKorbel
Nearly a Posting Virtuoso
1,215 posts since Feb 2011
Reputation Points: 482
Solved Threads: 239
Skill Endorsements: 12