⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagemanager.java

📁 java 调用windows的api
💻 JAVA
字号:
package org.jawin.browser.image;

import java.util.HashMap;
import javax.swing.ImageIcon;
import java.awt.*;
import org.jawin.browser.log.Log;

/**
 * <p>Title: Jawin Code Generation GUI</p>
 * <p>Description: GUI for exploring type libraries and generating Java code</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Open Source Incentive</p>
 * @author Josh Passenger
 * @version 1.0
 */

public class ImageManager
{
	private static ImageManager instance = null;
	private HashMap images = null;
	private MediaTracker tracker = new MediaTracker(new Canvas());

	private ImageManager()
	{
		images = new HashMap();
	}

	public static synchronized void initialize()
	{
		instance = new ImageManager();
	}

	public static ImageManager getInstance()
	{
		if (instance == null)
		{
			throw new IllegalStateException("ImageManager.getInstance() the image manager was not intilialized");
		}

		return instance;
	}

	/**
	 * @todo load images from a jar
	 *
	 * @param imageLocation the new image location
	 * @return the loaded (and cached image)
	 */
	public ImageIcon getImage(String imageLocation)
	{
		ImageIcon image = null;

		if (!images.containsKey(imageLocation))
		{
			image = new ImageIcon(getClass().getResource(imageLocation));

			while (image.getImageLoadStatus() == MediaTracker.LOADING)
			{
				try
				{
					Thread.currentThread().wait(200);
				}
				catch (InterruptedException e)
				{

				}
			}

			if (image != null && image.getImageLoadStatus() == MediaTracker.COMPLETE)
			{
				images.put(imageLocation, image);
			}
			else
			{
				System.out.println("ERROR: ImageManager.getImage() failed to load image: " + imageLocation);
			}
		}
		else
		{
			image = (ImageIcon) images.get(imageLocation);
		}

		return image;
	}
}

⌨️ 快捷键说明

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