import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* <p>Title: Applet使用jar包</p>
* <p>Description: 將類文件和圖片等資源文件打包,一次下載到本地。
本實例演示Applet使用這些資源</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Filename: 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();
}
}
}