applet 运行时出问题了

我编写了个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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值