这样做有什么问题吗:
public static Image getPicture01()
{
Applet app = new Applet();
Image t = app.getImage(app.getClass().getResource("/res/pic01.png"));
return t;
}
我的目标是从我的 Java 项目中获取资源(图像)并使用它。
最佳答案
Is there anything wrong with doing this:...
是的,这完全没有必要,很浪费(创建一个不需要的对象,Applet),并且有更好的选择——ImageIO.read(...) 之一。
关于java - 创建小程序获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7844589/