java swt label 怎么设置图片 setImage(new Image(device, data))

2025-01-06 05:06:08
推荐回答(3个)
回答1:

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;
}
}

回答2:

你是说想给标签设置图片?

回答3:

我也是刚学着