第14章多媒体编程 ava 14.1显示图像 142播放动画 143播放音频 144习题
第14章 多媒体编程 14.1 显示图像 14.2 播放动画 14.3 播放音频 14.4 习题
14.1显示图像 ava 141.1使用 Applet类 14.12使用 Imageicon类 14.1.3使用 Mediatracker类跟踪图像下载
14.1 显示图像 14.1.1 使用Applet类 14.1.2 使用ImageIcon类 14.1.3 使用MediaTracker类跟踪图像下载
14.1.1使用App1e类 ava 获取图像对象的方法: public Image getImage(URL url public Image getImage (URI url String name) 例: Image imagel=getImage(getCodeBase( mage\Tl.gif")i //在当前 applet所在目录的子目录mage中装入指定图像文件 Image image2=getImage( getDocumentBase(),Tl. gif)i //在包含当前 applet的HIM文件所在目录中装入指定图像文件
14.1.1 使用Applet类 获取图像对象的方法: – public Image getImage(URL url) – public Image getImage(URL url, String name) 例: Image image1=getImage(getCodeBase(), "image\T1.gif"); //在当前applet所在目录的子目录image中装入指定图像文件 Image image2=getImage( getDocumentBase(),"T1.gif"); //在包含当前applet的HTML文件所在目录中装入指定图像文件
141.1使用盘 opnet类(续)闆 显示图像的方法: public abstract boolean draw Image (Image img int x, int y, Imageobserver observer) public abstract boolean drawImage(Image img int x, int y, int width, int height ImageObserver observer 例14-1使用 Applet类 源代码 运
14.1.1 使用Applet类(续) 显示图像的方法: public abstract boolean drawImage(Image img, int x, int y,ImageObserver observer) public abstract boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) 例14-1 使用Applet类 源代码 运 行
141.2使用 Imageicon类 Imageicon类的构造方法: public ImageIcon(string filename) public ImageIcon (Image image public ImageIcon(URI location)
14.1.2 使用ImageIcon类 ImageIcon类的构造方法: – public ImageIcon(String filename) – public ImageIcon(Image image) – public ImageIcon(URL location)