Patrick Java
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 1/2/2025 in #java-help
Java GUI not loading images/ImageIcons help
like
ImageIcon img = new ImageIcon(Main.class.getResource("/Pictures/yippee.jpg"));
if Pictures is your resources root folder, do like this
ImageIcon img = new ImageIcon(Main.class.getResource("yippee.jpg"));
9 replies
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 1/2/2025 in #java-help
Java GUI not loading images/ImageIcons help
place images in resources folder, then load them using getResource() or you can use relative path referencing "/Pictures " uses absolute referencing and tries to locate /Pictures from the root file system
9 replies