Adding image to JFrame

user2612619 picture user2612619 · Aug 3, 2013 · Viewed 169.3k times · Source

So I am using Eclipse with Windows builder. I was just wondering if there was anyway I can import an image that'll show up on the JFrame that I can easily move around and re-size instead of setting the location and size and drawing it.

Answer

Rollyng picture Rollyng · Aug 3, 2013

Here is a simple example of adding an image to a JFrame:

frame.add(new JLabel(new ImageIcon("Path/To/Your/Image.png")));