seesharper
seesharper

Reputation: 147

Creating an applet to get an image

Is there anything wrong with doing this:

public static Image getPicture01()
{
    Applet app = new Applet();
    Image t = app.getImage(app.getClass().getResource("/res/pic01.png"));
    return t;
}

My goal is to get a resource (image) from my project in Java, and use it.

Upvotes: 1

Views: 44

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285403

Is there anything wrong with doing this:...

Yes, it is totally unnecessary, wasteful (creating an unneeded object, Applet), and there are better alternatives -- ImageIO.read(...) for one.

Upvotes: 3

Related Questions