wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.vci.client.ui;
 
import javax.swing.ImageIcon;
 
/**
 * 获取所有系统配置图片,所有新建项目须在src下建立images文件夹,并将当前工程下的图片放在此文件夹下,通过本工具类进行获取。
 * 工程中的文件名称需加入前缀,避免与其他工程同名
 * @author platform-001
 *
 */
public class ImageBundle {
 
private String path = "/images/"; //the path of images's folder
    
    public ImageBundle()
    {
    } 
    
    public String getPath() {
        return this.path;
    }
    
    /**
     * set the path of image's folder, or use the default
     * 
     * @param path
     */
    public void setPath(String path) {
        this.path = path;
    }
 
    /**
     * create a new ImageIcon and return it
     * 
     * @param fileName
     * @return
     */
    public ImageIcon createImageIcon(String fileName){
        ImageIcon icon = new ImageIcon("");
        if (fileName == null || fileName.length() == 0) {
            return icon;
        }
        if (path == null || path.length() == 0) {
            return icon;
        }
        try {
            icon = new ImageIcon(ImageBundle.class.getResource(path + fileName));
        } catch (Exception e) {
        }
      return icon;
    }
}