Loading Image in Java Applet

后端 未结 4 604
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 21:18

When I try to run an applet in applet viewer it is not able to find resources (Image). I try to load resource like this:

String cb= this.getCodeBase().toString()         


        
4条回答
  •  野性不改
    2021-01-21 22:04

    The context classloader should work with jars.

    ClassLoader cl = Thread.getContextClassLoader();
    ImageIcon icon = new ImageIcon(cl.getResource("something.png"), "description");
    

提交回复
热议问题