label.setIcon(ImageUtil.getImageIcon("login.jpg"));
public class ImageUtil {
public static ImageIcon getImageIcon(String name){
ImageIcon icon = null;
URL url = ImageUtil.class.getResource("/"+name);
if(url!=null)
icon = new ImageIcon(url);
return icon;
}
}
你是说想给标签设置图片?
我也是刚学着