import java.awt.*;(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
import java.awt.event.*;
import javax.swing.*;
/**
* pTitle: Applet使用jar包/p
* pDescription: 将类文件和图片等资源文件打包,一次下载到本地。
本实例演示Applet使用这些资源/p
* pCopyright: Copyright (c) 2003/p
* pFilename: ImageButtonApplet.java/p
* @version 1.0
*/
public class ImageButtonApplet extends JApplet
{
private String path = "/img/ittoolbox.gif";
private ImageIcon LogoButtonIcon = new ImageIcon(getClass().getResource(path));
/**
*br方法说明:初始化Applet,添加带图片的按钮
*br输入参数:
*br返回类型:
*/
public void init()
{
try
{
if (LogoButtonIcon == null)
throw new Exception("cannot get the image!");
JButton iButton = new JButton(LogoButtonIcon);
Container cp = this.getContentPane();
cp.add(iButton);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}