01: package org.jsqltool.utils;
02:
03: import java.awt.Image;
04: import javax.swing.ImageIcon;
05:
06: /**
07: * <p>Title: JSqlTool Project</p>
08: * <p>Description: This singleton class can be used to load an icon image from file system.
09: * </p>
10: * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
11: *
12: * <p> This file is part of JSqlTool project.
13: * This library is free software; you can redistribute it and/or
14: * modify it under the terms of the (LGPL) Lesser General Public
15: * License as published by the Free Software Foundation;
16: *
17: * GNU LESSER GENERAL PUBLIC LICENSE
18: * Version 2.1, February 1999
19: *
20: * This library is distributed in the hope that it will be useful,
21: * but WITHOUT ANY WARRANTY; without even the implied warranty of
22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23: * Library General Public License for more details.
24: *
25: * You should have received a copy of the GNU Library General Public
26: * License along with this library; if not, write to the Free
27: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28: *
29: * The author may be contacted at:
30: * maurocarniel@tin.it</p>
31: *
32: * @author Mauro Carniel
33: * @version 1.0
34: */
35: public class ImageLoader {
36:
37: /** unique istance of the class */
38: private static ImageLoader imgLoader = null;
39:
40: public static ImageLoader getInstance() {
41: if (imgLoader == null)
42: imgLoader = new ImageLoader();
43: return imgLoader;
44: }
45:
46: /**
47: * @param imageName image file name
48: * @return image icon object
49: */
50: public final ImageIcon getIcon(String imageName) {
51: // org.jsqltool.MainApp.class.getResourceAsStream(...)
52: return new ImageIcon(imgLoader.getClass().getClassLoader()
53: .getResource("images/" + imageName));
54: }
55:
56: }
|