
谢谢了!
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ImageTest extends JFrame
{
private static final long serialVersionUID = 1L;
public ImageTest()
{
setSize(800, 600);
setLocation(100, 100);
Icon iconObj = new ImageIcon("res\\default.gif");
JLabel jl = new JLabel(iconObj);
getContentPane().add(jl);
setVisible(true);
}
public static void main(String[] args)
{
new ImageTest();
}
}
问题是如何打包了也能正常使用
我记得好像应该把res文件夹放在jar所在的同一个目录下,就是不用打包进去,试试看