请问怎样在小应用程序中显示图象啊?
//<applet code=test.class width=200 height=200>
//</applet>
import java.applet.*; import java.awt.*; import java.net.*; import java.applet.Applet;
public class test extends Applet { public void paint(Graphics g) { try{ URL codebase=new URL("file:/d/imge/1.gif"); Image a=getImage(codebase); g.drawString("getfile="+codebase.getFile(),10,30); g.drawImage(a,10,50,this); } catch(MalformedURLException e) { g.drawString("Image not found",30,30); } }
} 怎么不行啊?
----------------解决方案--------------------------------------------------------
setVisible(true);
----------------解决方案--------------------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.net.*;
public class test extends JApplet
{
public void paint(Graphics g)
{
try{
URL codebase=new URL(getCodeBase(),("file:/d/imge/1.gif");
Image a=getImage(codebase);
g.drawString("getfile="+codebase.getFile(),10,30);
g.drawImage(a,10,50,this);
}
catch(MalformedURLException e)
{
g.drawString("Image not found",30,30);
}
}
}
这样就可以了 至于你那个为什么不行 我也不太清楚
----------------解决方案--------------------------------------------------------
不太清楚
----------------解决方案--------------------------------------------------------
applet can not loat the native resource
----------------解决方案--------------------------------------------------------
顶下下
----------------解决方案--------------------------------------------------------