-
大小: 199KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-06-08
- 语言: Java
- 标签: Swing+MySQL
资源简介
代码片段和文件信息
package com.swtdesigner;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import javax.swing.ImageIcon;
/**
* Utility class for managing resources such as colors fonts images etc.
*
* This class may be freely distributed as part of any application or plugin.
*
* Copyright (c) 2003 - 2004 Instantiations Inc.
All Rights Reserved
*
* @author scheglov_ke
*/
public class SwingResourceManager {
/**
* Maps image names to images
*/
private static HashMap m_ClassImageMap = new HashMap();
/**
* Returns an image encoded by the specified input stream
* @param is InputStream The input stream encoding the image data
* @return Image The image encoded by the specified input stream
*/
private static Image getImage(InputStream is) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte buf[] = new byte[1024 * 4];
while (true) {
int n = is.read(buf);
if (n == -1)
break;
baos.write(buf 0 n);
}
baos.close();
return Toolkit.getDefaultToolkit().createImage(baos.toByteArray());
} catch (Throwable e) {
return null;
}
}
/**
* Returns an image stored in the file at the specified path relative to the specified class
* @param clazz Class The class relative to which to find the image
* @param path String The path to the image file
* @return Image The image stored in the file at the specified path
*/
public static Image getImage(Class> clazz String path) {
String key = clazz.getName() + ‘|‘ + path;
Image image = m_ClassImageMap.get(key);
if (image == null) {
if ((path.length() > 0) && (path.charAt(0) == ‘/‘)) {
String newPath = path.substring(1 path.length());
image = getImage(new BufferedInputStream(clazz.getClassLoader().getResourceAsStream(newPath)));
} else {
image = getImage(clazz.getResourceAsStream(path));
}
m_ClassImageMap.put(key image);
}
return image;
}
/**
* Returns an image stored in the file at the specified path
* @param path String The path to the image file
* @return Image The image stored in the file at the specified path
*/
public static Image getImage(String path) {
return getImage(“default“ path); //$NON-NLS-1$
}
/**
* Returns an image stored in the file at the specified path
* @param section String The storage section in the cache
* @param path String The path to the image file
* @return Image The image stored in the file at the specified path
*/
public static Image getImage(String section String path) {
String key = section + ‘|‘ + SwingResourceManager.class.getName() + ‘|‘ + path;
Image image = m_ClassImageMap.get(key);
if (image == null) {
try {
F
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
.CA.... 9532 2010-09-05 21:12 宾馆客房管理系统\hotel.sql
.CA.... 483 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\.classpath
.CA.... 391 2010-07-28 09:28 宾馆客房管理系统\hotelmanagement\.project
.CA.... 4570 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\com\swtdesigner\SwingResourceManager.class
.CA.... 811 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Addcost$1.class
.CA.... 1139 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Addcost$2.class
.CA.... 783 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Addcost$3.class
.CA.... 3173 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Addcost.class
.CA.... 1334 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Addcost_Bean.class
.CA.... 1964 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Addcost_Util.class
.CA.... 806 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\customerManage\Client$1.class
.CA.... 2508 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\customerManage\Client$2.class
.CA.... 777 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\customerManage\Client$3.class
.CA.... 3977 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\customerManage\Client.class
.CA.... 1761 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Client_Bean.class
.CA.... 1985 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Client_Util.class
.CA.... 796 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Cost$1.class
.CA.... 2358 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Cost$2.class
.CA.... 853 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Cost$3.class
.CA.... 765 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Cost$4.class
.CA.... 3014 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\Cost.class
.CA.... 2449 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\customerManage\CostUtil.class
.CA.... 925 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\db\JDBC.class
.CA.... 815 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\formManage\Accout_form$1.class
.CA.... 2457 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\formManage\Accout_form$2.class
.CA.... 814 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\formManage\Accout_form$3.class
.CA.... 787 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\formManage\Accout_form$4.class
.CA.... 3288 2010-12-15 04:39 宾馆客房管理系统\hotelmanagement\bin\formManage\Accout_form.class
.CA.... 805 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\formManage\Cost_form$1.class
.CA.... 2369 2010-12-15 04:31 宾馆客房管理系统\hotelmanagement\bin\formManage\Cost_form$2.class
............此处省略167个文件信息
评论
共有 条评论