【发布时间】:2013-01-25 12:40:12
【问题描述】:
我有一个加载图标数组的类,我的小程序使用 2 个这样的数组,一个用于图像,一个用于缩略图。 我有一个动画线程,它通过缩略图数组旋转一组 6 个缩略图,以及一个允许滚动缩略图的滑块。
当我使用 applet-viewer 时,程序运行良好,但是如果我打包 applet 并在浏览器上查看它,或者如果我将未打包的 applet 上传到网站上,则缩略图,但不是使用相同类加载的图像不显示在屏幕上,缩略图附带的功能变得滞后。
我不能保证网站不会改变,但您可以尝试在http://tokweweb.uphero.com/ 亲自查看错误
这是给我问题的类的代码:
谢谢
public class IconArray {
private ImageIcon[] Icons;
private int Count;
private String Filepath;
IconArray(String filepath, int count){
Count = count;
Icons = new ImageIcon[Count];
Filepath = filepath;
}
IconArray(String filepath, int count, boolean Autoload){
Count = count;
Icons = new ImageIcon[Count];
Filepath = filepath;
if(Autoload){
for(int i = 0; i<Count; i++){
Icons[i] = new ImageIcon(getClass().getResource(Filepath+i+".jpg"));
}
}
}
public Icon GetIcon(final int i) throws InterruptedException{
if(Icons[i]!=null){
return Icons[i];
}else{
Integer temp = new Integer(i);
Icons[i] = new javax.swing.ImageIcon(getClass().getResource(Filepath+temp.toString()+".jpg"));
return Icons[i];
}
}
public int GetCount(){
return Count;
}
}
【问题讨论】:
-
考虑逐步削减您的代码以尝试隔离问题。这样,您要么找到错误,要么最终得到一个非常小的可编译和可运行的程序来演示您的问题,您可以在此处发布。
-
你的小程序抛出类版本异常?..
-
@DanglingPiyush:一开始我也这么认为;看起来对类文件的请求正在返回
404。 -
从外观上看,这绝对是应该在小程序内完成的事情。用户无法从信息中复制/粘贴文本,并且与搜索引擎完全不兼容。