为什么程序不能运行?
whwyw 2003-06-30 11:52:26 我用ECLIPSE 根据书上例程建立如下代码.但不能运行.请帮助
/*
* Created on 2003-6-30
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package ex;
import java.applet.Applet;
import java.awt.*;
/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class ex518 extends Applet{
Frame f;
MenuBar mb;
Menu file;
public void init(){
f=new Frame();
mb=new MenuBar();
file=new Menu("file");
file.add(new MenuItem("new"));
mb.add(file);
f.setMenuBar(mb);
f.resize(300,400);
add(f);
f.show();
}
public boolean handleEvent(Event evt){
switch(evt.id){
case(Event.ACTION_EVENT):
if(evt.target instanceof MenuItem){
if("new".equals(evt.arg))System.out.println("new");
}
return true;
default:
return false;
}
}
}