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

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -