//我的代码
//制作记事本import java.awt.*;
import java.awt.event.*;//frame
public class Notepad extends Frame{

TextArea ta;
MyMenuBar mmb; public Notepad(){          //构造器

//mmb=new MyMenuBar(new String[]{"file","edit","format","color","help"});
mmb=new MyMenuBar();
this.setMenuBar(mmb);

ta=new TextArea();
this.add(ta); this.addWindowListener(new NListener());
} public static void main(String[] args){
Notepad n=new Notepad();
n.setTitle("Notdpad");
n.setBounds(200,200,700,500);
n.setVisible(true);
}
}
//MyMenuBar
class MyMenuBar extends MenuBar{ private Menu file=new Menu("file");
private Menu edit=new Menu("edit");
private Menu format=new Menu("format");
private Menu color=new Menu("color");
private Menu help=new Menu("help"); private MenuItem file_new=new MenuItem("New");
private MenuItem file_open=new MenuItem("Open");
private MenuItem file_save=new MenuItem("Save");
private MenuItem file_exit=new MenuItem("Exit"); private MenuItem edit_copy=new MenuItem("Copy");
private MenuItem edit_plaster=new MenuItem("Plaster"); private MenuItem format_font=new MenuItem("Font"); private MenuItem color_yellow=new MenuItem("Yellow"); private NListener nl=new NListener(); public MyMenuBar(){
file.add(file_new);
file.add(file_open);
file.add(file_save);
file.add(file_exit); edit.add(edit_copy);
edit.add(edit_plaster);

format.add(format_font); color.add(color_yellow);

this.add(file);
this.add(edit);
this.add(format);
this.add(color);
this.add(help);

file_new.addActionListener(nl);
file_open.addActionListener(nl);
file_save.addActionListener(nl);
file_exit.addActionListener(nl); edit_copy.addActionListener(nl);
edit_plaster.addActionListener(nl); format_font.addActionListener(nl); color_yellow.addActionListener(nl);

}


/*public MyMenuBar(String[] s){
for(int i=0;i<s.length;i++){
this.add(new Menu(s[i]));

}
}*/

}//listener
class NListener implements WindowListener,ActionListener{ public void windowActivated(WindowEvent e){}//WindowListener
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){} public void actionPerformed(ActionEvent e){
if(e.getActionCommand()=="file_new"){
ta.setText(null);//---------------------这里找不到ta
}
} /*public void itemStateChanged(ItemEvent e){

}*/
}
大哥大姐给个提示就好