| import java.applet.*; import java.awt.*; public class imag0 extends Applet{ Image image; public void init() { image=getImage(getDocumentBase(),"test.gif"); } public void paint(Graphics g) { g.drawImage(image, 0, 0,this); } } |
| String url = "结点URL"; Image image; try { image = getImage(new URL(url)); } catch(Exception e){ System.out.println("Can´t open the URL "); } |
| URL imgur=null; Image image; try { imgur=new URL("结点URL "); } catch (MalformedURLException e) { System.out.println("Can´t open the URL "); } image=getImage(imgur); |
| import java.applet.*; import java.net.*; import java.awt.*; public class imag extends Applet{ Image image; public void init() { String url = "http://www.shu.edu.cn/~xyx/img/shnet.jpg"; try { image = getImage(new URL(url)); } catch(Exception e){} } public void paint(Graphics g) { g.drawImage(image, 0, 0,this); } } |
| import java.applet.*; import java.net.*; import java.awt.*; public class imag2 extends Applet{ Image image; URL imgur=null; public void init() { try { imgur=new URL("http://www.shu.edu.cn/~xyx/img/shnet.jpg"); } catch (MalformedURLException e) { System.out.println("Can´t open the URL "); } image=getImage(imgur); } public void paint(Graphics g) { g.drawImage(image, 0, 0,this); } } |
| < html > < head > < title >Example < /title > < /head > < center > < applet code=imag.class width=550 height=250 > < /applet > < /html > |
| 第1页: Java编程简介 | 第2页: Java网络功能及获取网络上资源的一般... |
| 第3页: 从网络上获得声音 | 第4页: 显示网络上其他HTML文档 |