java - There is a Jpanel that opens when running from eclipse and after exporting as executable jar it won't open -


i'm creating game called lines of actions , facing problem here when exporting executable jar file

http://s21.postimg.org/rk1jef9wn/untitled.png

when press button "two players" panel should shown

http://s21.postimg.org/dvcclaz8n/untitled.png

and show when run eclipse doesn't when run executable jar file

note: images in images source folder , i'm using method image:

private imageicon image(string s) {     return new imageicon(getclass().getclassloader().getresource(s)); } 

and when creating jlable :

new jlabel(image("example.png")); 

while project this:

http://s14.postimg.org/lkuqvzut9/untitled.png

run jar console java -jar filename.jar. have null on of resources (images).

you can see errors , warnings in console, clicking jar won't let that.

to comment below: try loading image jpanel same way loading main background images (for title/options menu), know work already. need inputstream loading resources within executable .jar.

getresourceasstream want use loading resources within executables. practice use this, within ide ( eclipse) exporting easier.

to question edit: getresource returns url happens null in case. try doing image("example.png"));. wrote .ong fileextension, if meant .png change , code should work :)

if didn't mean write .ong try adding backslash filename so: image("/example.png"); can read in link above why.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -