Subversion Repositories svn.mios

Rev

Rev 213 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 213 Rev 628
Line 1... Line 1...
1
/*
1
/*
2
 * @(#)ImageLoader.java beta7   2006/04/23
-
 
-
 
2
 * @(#)ImageLoader.java beta8   2006/04/23
3
 *
3
 *
4
 * Copyright (C) 2006    Adam King (adamjking@optusnet.com.au)
-
 
-
 
4
 * Copyright (C) 2008    Adam King (adamjking@optusnet.com.au)
5
 *
5
 *
6
 * This application is free software; you can redistribute it and/or modify
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
9
 * (at your option) any later version.
Line 22... Line 22...
22
22
23
import java.net.URL;
23
import java.net.URL;
24
import java.util.Hashtable;
24
import java.util.Hashtable;
25
25
26
import javax.swing.ImageIcon;
26
import javax.swing.ImageIcon;
27
import java.io.File;
-
 
-
 
27
28
public class ImageLoader {
28
public class ImageLoader {
29
29
30
    private static Hashtable images = new Hashtable();
30
    private static Hashtable images = new Hashtable();
31
31
32
    public static ImageIcon getImageIcon(String imageName) {
32
    public static ImageIcon getImageIcon(String imageName) {
Line 34... Line 34...
34
        ImageIcon imageIcon;
34
        ImageIcon imageIcon;
35
35
36
        if (images.containsKey(imageName)) {
36
        if (images.containsKey(imageName)) {
37
            imageIcon = (ImageIcon) images.get(imageName);
37
            imageIcon = (ImageIcon) images.get(imageName);
38
        } else {
38
        } else {
39
            //ClassLoader cl = ImageLoader.class.getClassLoader();
-
 
40
            //URL url = cl.getResource("images/" + imageName);
-
 
41
            URL url = ImageLoader.class.getResource("/images/" + imageName);
-
 
-
 
39
-
 
40
            ClassLoader cl = ImageLoader.class.getClassLoader();
-
 
41
            URL url = cl.getResource("images/" + imageName);
42
            imageIcon = new ImageIcon(url);
42
            imageIcon = new ImageIcon(url);
43
            images.put(imageName, imageIcon);
43
            images.put(imageName, imageIcon);
44
        }
44
        }
45
        return imageIcon;
45
        return imageIcon;
46
    }
46
    }