Answer the question
In order to leave comments, you need to log in
Java swing. Can't add image and icon. How to be?
I made a launcher using Eclipse swing windowbuiler. After inserting the image using "absolute path". (It even said "Use only for quick testing, never use in real application". I inserted pictures for the Jframe icon itself, and as a simple picture as jlabel. Naturally, after compiling the jar file and opening it on another computer, there are no pictures. I understood that it does not load these pictures into the jar file itself. Googled for a long time. Transferred the pictures to the project folder. First in src, then simply indicated the path "src/image.jpg" and "/image.jpg", "image.jpg" "He just didn't see them. Then he created the img folder in parallel with src, threw them there, there was no effect. I tried to use
String iconpath1 = "1_QQL3nsLnggRfUCnldn0i7w (3).jpeg";
File icon = new File(iconpath1);
ImageIcon imgicon = new ImageIcon(iconpath1);
Answer the question
In order to leave comments, you need to log in
Pulled from a very old code:
ImageIcon icSave = new ImageIcon(SignalProcess.class.getResource("/resources/save64.png"));
Resources packed inside jar
First, you need to understand what a JAR is, how it is packaged, how it works, how runtime works with it, etc. Secondly, you need to familiarize yourself with the concept of "resource" and learn how to work with resources in Java. Thirdly, you need to read the Maven documentation on how it works with resources.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question