objcreateappletimage.java

来自「java数据库编程。JDBC+SQL+GUI。用java写的一个影碟租赁系统」· Java 代码 · 共 41 行

JAVA
41
字号
//Vedio rental System Developed by Banu
// this code will create the image for the icon that display on the toolbar buttons

import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import javax.swing.ImageIcon;

public class objCreateAppletImage
{

	public static ImageIcon getImageIcon (String path, String description, int fileSize) throws Exception
	{
				
		int count = 0;
		BufferedInputStream imgStream = new BufferedInputStream(new FileInputStream(path));
		byte buff[] = new byte[fileSize];
		
		if (imgStream == null) //If doesn't exist
		{
			throw new Exception("File not Found");
		}
		
		try
		{
					
			count = imgStream.read(buff);
			imgStream.close();
			
		}
		catch (IOException ex)
		{
			throw new Exception("Corrupt file");
		}
		
		return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buff), description);
		
	}
	
}	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?