import java.awt.*;
import java.awt.event.*;
public class DrawImage
{
public static void main(String [] args)
{
Frame f=new Frame( "IT communication 's net ");
Image img=f.getToolkit().getImage( "c:\\test.gif ");
f.getGraphics().drawImage(img,0,0,f);
f.setSize(500,500);
f.setVisible(true);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
e.getWindow().setVisible(false);
((Window)e.getComponent()).dispose();
System.exit(0);
}
});
}
}
为什么用JCreator运行时出现
Exception in thread "main " java.lang.NullPointerException at DrawImage.main(DrawImage.java:9)
------解决方案--------------------
不用加C盘。。直接放在你的.java目录下,就可以了。