繁体   English   中英

Applet不想在浏览器中打开

[英]Applet doesn't want to open in browser

我的小程序不想在浏览器中打开。 我认为这都是由于图形。

我这样加载:

icon = new ImageIcon(getClass().getResource("logo.png"));

并像这样使用:

logo = new JLabel(icon);

没有图形,一切都会好起来的。

使用类加载器查找jar文件中捆绑的图像。

ClassLoader classLoader = this.getClass().getClassLoader();

URL imageURL = classLoader.getResource("images/icon.logo");
JLabel logo = new JLabel(new ImageIcon(imageURL));

也可以看看:


更新

 +Project
 |
 |   
 +-src
 |  |
 |  |   
 |  +path
 |  |
 |  |-TargetClass.java
 |  ...
 |
 +-resources
 |  |
 |  |
 |  +-images       
 |  |    |
 |  ...  |-icon.logo
 ...     ...  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM