00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.util;
00023
00024 import java.io.IOException;
00025 import java.net.URL;
00026 import javax.swing.ImageIcon;
00027 import org.jetbrains.annotations.NotNull;
00028
00033 public class ResourceUtils {
00034
00038 @NotNull
00039 public static final String UNKNOWN_PNG = "unknown.png";
00040
00044 @NotNull
00045 public static final String NEXT_GROUP_FACE = "next_group.png";
00046
00050 @NotNull
00051 public static final String PREV_GROUP_FACE = "prev_group.png";
00052
00056 @NotNull
00057 public static final String APPLICATION_ICON = "application_icon.png";
00058
00062 private ResourceUtils() {
00063 }
00064
00071 @NotNull
00072 public static ImageIcon loadImage(@NotNull final String name) throws IOException {
00073 final URL url = ResourceUtils.class.getClassLoader().getResource("resource/"+name);
00074 if (url == null) {
00075 throw new IOException("cannot find image '"+name+"'");
00076 }
00077 final ImageIcon imageIcon = new ImageIcon(url);
00078 if (imageIcon.getIconWidth() <= 0 || imageIcon.getIconHeight() <= 0) {
00079 throw new IOException("cannot load image '"+name+"'");
00080 }
00081 return imageIcon;
00082 }
00083
00084 }