我知道这个问题的留言板上有一千个答案,我已经尝试了所有答案,但无论出于何种原因,它们都没有奏效。这是我的代码的摘录:
ImageIcon icon = new ImageIcon("/home/james/programmingpics/A_Flute");
ImageIcon icon1 = new ImageIcon("/home/james/programmingpics/C_D_Flute");
ImageIcon icon2 = new ImageIcon("/home/james/programmingpics/D_E_Flute");
ImageIcon icon3 = new ImageIcon("/home/james/programmingpics/E_Flute");
ImageIcon icon4 = new ImageIcon("/home/james/programmingpics/F_G_Flute");
ImageIcon icon5 = new ImageIcon("/home/james/programmingpics/G_Flute");
ImageIcon icon6 = new ImageIcon("/home/james/programmingpics/B_Flute");
ImageIcon icon7 = new ImageIcon("/home/james/programmingpics/C_Flute");
ImageIcon icon8 = new ImageIcon("/home/james/programmingpics/D_Flute");
ImageIcon icon9 = new ImageIcon("/home/james/programmingpics/F_Flute");
非常简单,在我的电脑上运行完美。每当我压缩 dist 文件夹时,将图片从计算机上的目录中移出并运行程序,我会得到空的 JFrame。所以我然后做了 project/properties/sources/add 文件夹的事情,编译它,结果还是一样。然后我将classes文件夹移动到dist文件夹中,尝试更改路径,看看是否有效,仍然没有。听起来有一个简单的答案,但我显然错过了它。