downloadimagethread.java

来自「手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环」· Java 代码 · 共 81 行

JAVA
81
字号
/*
 * @(#)DownloadImageThread.java	1.11 01/08/23
 * Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
 * @version 	1.0, 10/05/2004
 * @author 	饶荣庆
 * @author 	余煜辉
 */

 /**
 *此common包是连网的共有包,为所有连网提供统一的接口
 */
package com.j2me.common;

import java.io.*;
import javax.microedition.lcdui.*;

/*
 *此类是为了提高网络下载速度的下载网络图片线程
 */
public class DownloadImageThread extends Thread
{

	/*定义要返回的对象*/
	private Displayable dis;
	private String imageURL;
	private boolean isOk;

	private Image image;

	public DownloadImageThread(String stringURL)// String imageURL, DowloandGuage dowloand, Displayable displayable, Displayable dis,)
	{
		this.imageURL = stringURL;
	}


	public void run() 
	{
		try
		{	
			//从网络上获取图象资源
			image = ConnectHttp.getJspImage(imageURL);
			isOk = true;				   
		}
		catch(IOException e)
		{
			System.out.println(e);
		}
		catch(NullPointerException e)
		{
			System.out.println(e);
		}
		catch(IllegalArgumentException e)
		{
			System.out.println(e);
	    }
	}

    /**
	 *判断是否下栽完成
	 */
	public boolean isOk()
	{
		return isOk;
	}

    /**
	 *返回图象
	 */
	public Image getImage()
	{
		if (image != null)
		{	
			return image;
		}
		else
		{
			return null;
		}
	}
}

⌨️ 快捷键说明

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