我编写了个applet小程序,结果在网页上出不来,大家帮我看看吧。
我第一个写的是html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>第一个网页</title>
</head>
<body>
<Applet code="Exam4_1.class" width="300" height="300"></Applet>
</body>
</html>
我第二个写的是applet
import java.applet.Applet;
import java.awt.Graphics;
public class Exam4_1 extends Applet
{
String str;
public void init()
{
str="here is an Applet";
}
public void paint(Graphics g)
{
g.drawString(str, 100, 100);
}
}
结果出现了下面问题,大家帮帮忙吧!
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
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.java: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(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.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)