代码分为三部分:界面、打开、保存
界面代码:
public void init() {
//外框
frame = new Frame("记事本");
frame.setVisible(true);
frame.setSize(1300, 900);
frame.setLocation(300, 400);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
//
MenuBar mb = new MenuBar();
Menu file = new Menu("文件");
help = new Menu("帮助");
MenuItem shelp = new MenuItem("帮助");
open = new MenuItem("打开");
save = new MenuItem("保存");
file.add(open);
file.add(save);
help.add(shelp);
ta = new TextArea();
ta.setFont(new Font("黑体",0,30));
frame.add(ta);
mb.add(file);
mb.add(help)