我开发了一个桌面应用程序。问题是当我将应用程序导出到 jar 文件时,应用程序中未显示图标。当我从 Eclipse 运行它时,所有图标都显示在那里。
我的项目中的一个例子:
package net.ebank.gui;
import java.awt.*;
import javax.swing.*;
public class EBank extends JFrame {
protected Start s;
public EBank() {
setTitle("Welcome To EBank");
setBackground(Color.white);
Image img = new ImageIcon("../EBank/res/bank.jpg").getImage();
this.setIconImage(img);
/*"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"*/
setVisible(false);
setSize(1350,700);
setDefaultCloseOperation(this.EXIT_ON_CLOSE);
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
s= new Start(this);
s.setLocation(getWidth()/2, getHeight()/4);
}
public static void main(String[] args){
new EBank();
}
}