Toolkit.getImage获取图片

时间:2023-11-23 16:26:14

Toolkit.getImage获取图片

public class Img {

    private static final Toolkit tk = Toolkit.getDefaultToolkit();
public static final Image getTankImageIsFriendly(Direction dir, boolean b) {
int j = getTankImage(dir);
String str = "image/Tank/green/Tank" + j + ".png";
if (b) {
str = "image/Tank/pink/Tank" + j + ".png";
}
Image img = tk.getImage(Img.class.getClassLoader().getResource(str));
// Image img = new ImageIcon(str).getImage();
return img;
}
}