加载中…
个人资料
脑细胞
脑细胞
  • 博客等级:
  • 博客积分:0
  • 博客访问:5,128
  • 关注人气:0
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
相关博文
推荐博文
谁看过这篇博文
加载中…
正文 字体大小:

java实验FirstApplet

(2007-03-19 20:58:29)

今天做的java实验

以下是源码和错误

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

/*
 *FirstApplet 类与我们玩“click-me-not”游戏
 */

public class FirstApplet extends Applet implements ActionListener
{
 private Button  clickMe;

 /**
  applet的init()方法
  */

 public void init()
 {
  clickMe=new Button("Click Me Not!");
  clickMe.addActionListener(this);
 
add(clickMe);
 //init()

 public void actionPerformed(ActionEvent e)
 {
  if (clickMe.getLabel().equals("Click Me!"))
     clickMe.setLabel("Click Me Not!");  
  else
     clickMe.setLabel("Click Me!");
 //actionPerformed
//End of FirstApplet

/***********去掉分号的错误*********************
FirstApplet.java:21: ';' expected
        } //init()
        ^
1 error
*************因为java程序是以“;”结束的。所以出现这样的错误
*/

/****************在Button前面加//时的错误!
*FirstApplet.java:20: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                clickMe=new Button("Click Me Not!");  
                ^
FirstApplet.java:21: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                add(clickMe);
                    ^
FirstApplet.java:26: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                if (clickMe.getLabel().equals("Click Me!"))
                    ^
FirstApplet.java:27: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                   clickMe.setLabel("Click Me Not!");
                   ^
FirstApplet.java:29: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                   clickMe.setLabel("Click Me!");
                   ^
5 errors
**********没有申明BUTTON所以执行时找不到*********

*/

 


/*******clickMe改成ClickMe的错误!**********
FirstApplet.java:20: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                clickMe=new Button("Click Me Not!");
                ^
FirstApplet.java:21: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                add(clickMe);
                    ^
FirstApplet.java:26: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                if (clickMe.getLabel().equals("Click Me!"))
                    ^
FirstApplet.java:27: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                   clickMe.setLabel("Click Me Not!");
                   ^
FirstApplet.java:29: cannot resolve symbol
symbol  : variable clickMe
location: class FirstApplet
                   clickMe.setLabel("Click Me!");
                   ^
5 errors
***************************************************
*/

 

/*
****在HTML文件中把文件名改成firstApple.class的错误java.lang.NoClassDefFoundError: firstApplet (wrong name: FirstApplet)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:157)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:123)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:561)
        at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
        at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
        at sun.applet.AppletPanel.run(AppletPanel.java:298)
        at java.lang.Thread.run(Thread.java:534)
****入了错误的文件名在寻找对应的class文件时找不到*****
*/

0

阅读 评论 收藏 转载 喜欢 打印举报/Report
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

      

    新浪BLOG意见反馈留言板 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有