I'm working on a game with a small team and they've opened a ticket to change the IconImage, which takes in an ImageIcon object.
I create an ImageIcon object with a java.net.URL pointing to the file location in the CLASSPATH. Then I create an Image object out of ImageIcon.getImage().
Later on in the program, I pass the Image object mentioned above to jframe.setIconImage();
If I run the program in debug, I can see the path to the image is correct, reflecting it's place in the CLASSPATH, but the icon doesn't change. If I step into jframe.setIconImage(), I get to a point where JFrame.java is calling JFrame.super.setIconImage(), but the value of image being passed to the super class is "" (empty string).
I have code in the main class, src folder structure, out/bin folder structure, and a picture of the value being passed as empty string.
Any advise at all is much appreciated and thanks in advance for your time.
==Code==
package orsc;
import orsc.Config;
import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
import java.io.File;
public class ORSCFrame extends ORSCApplet {
private static final long serialVersionUID = 1L;
public String getCacheLocation() {
return Config.F_CACHE_DIR + File.separator;
}
public static void main(String[] args) {
JFrame jframe = new JFrame(Config.SERVER_NAME);
ImageIcon orscIcon = new ImageIcon(ORSCFrame.class.getResource("icon.png"));
Image orscIconImage = orscIcon.getImage();
final Applet applet = new ORSCFrame();
applet.setPreferredSize(new Dimension(512, 334 + 12));
jframe.getContentPane().setLayout(new BorderLayout());
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.getContentPane().add(applet);
jframe.setResizable(true);
jframe.setVisible(true);
// jframe.setAlwaysOnTop(true);
jframe.setBackground(Color.black);
jframe.setMinimumSize(new Dimension(512, 334 + 12));
jframe.setIconImage(orscIconImage);
jframe.pack();
jframe.setLocationRelativeTo(null);
applet.init();
applet.start();
// jframe.add(applet);
}
@Override
public void playSound(byte[] soundData, int offset, int dataLength) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void stopSoundPlayer() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
== src folder ==
==out/bin folder ==
==step into line 33 (jframe.setIconImage(orscIconImage);) ==
==pic of jframe ==