Loading images in Java Web Start applet -


in normal applets, use load images jlabels

    image back2 = getimage(getdocumentbase(), "images/blank_blue.png");     imageicon background2icon = new imageicon(back2);     jlabel pic2 = new jlabel(background2icon); 

when tried doing java web start applet, nothing appeared. in java console, said basic: loaded image: file:/c:/users/jdfksl/desktop/webstarttest/images/blank_blue.png , there no error, wouldn't appear.

i got images load in jlabels work in java web start way

bufferedimage image=null;         classloader classloader = thread.currentthread().getcontextclassloader();         try {             image = imageio.read(classloader.getresourceasstream("images/ghast_skin.png"));         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         } 

but, wanted shorter way of loading images. there other option?

this jnlp file content

     <?xml version="1.0" encoding="utf-8"?>  <jnlp href="jws_tester.jnlp">      <information>        <title>jws tester</title>        <vendor>htz.</vendor>        <description>testing jws</description>        <offline-allowed />      </information>      <resources>        <j2se version="1.4+"              href="http://java.sun.com/products/autodl/j2se" />        <jar href="tester.jar" main="true" />        <!-- specify if using jnlp extensions                                 <extension name="someextension"                   href="http://some.server.com/some_extension.jnlp" />                                 -->      </resources>       <security>     <all-permissions/> </security>       <applet-desc           name="jws tester"          main-class="mather.main"          width="900"          height="600">      </applet-desc>  </jnlp> 

one way add images build path , access image class this.

new imageicon(testclass.class.getresource("/image.png")); 

in approach image added jar file jar file may bulkier.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -