怎么搞的,出现以下问题。
import java.awt.*;
import java.applet.Applet;
public class DrawMyImage extends Applet
{
Image myImage;
public void init()
{
myImage=getImage(getCodeBase(), "images\\001.gif ");
}
public void paint(Graphics g)
{
g.drawImage(myImage,0,0,this);
}
}
AppletViewer 后。
没有图像出来。
关闭后出现以下大量异常:
D:\java\lesson6> AppletViewer DrawMyImage.java
Exception in thread "AWT-EventQueue-0 "
java.lang.NullPointerException: disposed
component
at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
at sun.awt.windows.Win32SurfaceData. <init> (Win32SurfaceData.java:448)
at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:316
)
at sun.awt.Win32GraphicsConfig.createSurfaceData(Win32GraphicsConfig.jav
a:357)
at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java
:332)
at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java
:313)
at sun.awt.windows.WComponentPeer$2.run(WComponentPeer.java:353)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
------解决方案--------------------回楼主代码 没问题
应该是你的gif的路径有问题
------解决方案--------------------试试images/001.gif