开发者

Problem with publishing the applet

开发者 https://www.devze.com 2023-01-31 11:22 出处:网络
I am trying to publish the applet on the web. I know the syntax of the <applet> tag, and the icons for the buttons I am using are in the same folder as all of the classes. I don\'t know what is

I am trying to publish the applet on the web. I know the syntax of the <applet> tag, and the icons for the buttons I am using are in the same folder as all of the classes. I don't know what is wrong. Here is the code:

<applet code="Bomb.class" codebase="..//..//build//classes" width="650" height="450">
<p>This requires a java-enabled browser</p>
</applet>

Ple开发者_开发知识库ase help. :(


While publishing an applet, you really should create a jar file with the Applet's classes and resources (such as images) in it. Then you can use Class's getResource to get a Url for it, like this:

ImageIcon myImage = new ImageIcon(this.getClass().getResource("/img.jpg"));

The / is necessary because of how Class's getResource works.


Try this

Image myImage= getImage(getDocumentBase(),"img.jpg");
ImageIcon imgIcon = new ImageIcon(myImage);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号