我正在处理一个Java项目,它包含图像。但是,当我将 Java 项目导出为可运行的 Jar 文件或仅导出 Jar 文件时,屏幕上不会显示任何图像。它在IDE中使用(日食)工作正常。我已经尝试了人们发布的所有方法。我也使我的res文件夹成为主文件夹。 newFrame.setTitle("Mustache Clicker"); jLabel1.setText(i + ""); URL mustache1 = mainscreen.class.getResource("/images/mustache.png"); ImageIcon mustache = new ImageIcon(mustache1); URL mustache2 = mainscreen.class.getResource("/images/Mustache Mine.png"); ImageIcon miner = new ImageIcon(mustache2); URL mustache3 = mainscreen.class.getResource("/images/Auto .png"); ImageIcon auto = new ImageIcon(mustache3); URL mustache4 = mainscreen.class.getResource("/images/mustache (1).png"); ImageIcon rain = new ImageIcon(mustache4); URL mustache5 = mainscreen.class.getResource("/images/city.png"); ImageIcon city = new ImageIcon(mustache5); jButton2.setIcon(miner); jButton1.setIcon(mustache); jButton3.setIcon(auto); jButton4.setIcon(rain); jButton5.setIcon(city);
添加回答
举报
0/150
提交
取消