added exception to deal with failure of ImageIcon constructor if X windows is not available

master
melvin 2011-05-22 16:16:59 +08:00
parent 24695ea1b7
commit 856d5703c5
1 changed files with 11 additions and 3 deletions

View File

@ -153,7 +153,13 @@ public class IconImages {
private static ImageIcon loadIcon(final String name) {
final BufferedImage image=loadImage("icons/"+name);
return image!=null?new ImageIcon(image):MISSING2;
ImageIcon icon = null;
try {
icon = new ImageIcon(image);
} catch (Error e) {
}
return image != null ? icon : MISSING2;
}
private static ImageIcon loadSymbolIcon(final String name) {
@ -182,6 +188,8 @@ public class IconImages {
return new ImageIcon(Arrays.copyOf(data,size));
} catch (final Exception ex) {
return MISSING2;
}
} catch (final Error er) {
return MISSING2;
}
}
}
}