java - image in a brand new jframe? -


i looking class create new jframe displaying image "rules.jpg" found in src folder of project.

edit: worked out how there, image still wont display when export jar, have tips?

to load image jar, need access differently. there nice swing tutorial doing that:

http://download.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource

here relevant code form tutorial:

java.net.url imageurl = mydemo.class.getresource("images/myimage.gif"); ... if (imageurl != null) {     imageicon icon = new imageicon(imageurl); } 

Comments

Popular posts from this blog

delphi - TJvHidDeviceController "DevicePath" always showing "\" -

Disabling Android home button for industry application -

asp.net mvc 3 - Unexpected "foreach" keyword after "@" character -