【求助】编的JAVA连连看小程序,测试图片不全怎么弄啊
private static Icon icons[] = new ImageIcon[6 * 5]; private static final String imgDir = "F:\\Java\\游戏\\LLK\\图片";
static {
try {
File dir = new File(imgDir);
File[] imgFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".jpg");
}
});
for (int i = 0; i <15; i++) {
icons[i] = new ImageIcon(imgFiles[i].getAbsolutePath());
//System.out.println(i+" "+icons[i]);
}
} catch (Exception e) {
e.printStackTrace();
}
}