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
Post a Comment