import *;import *;import *;import *;import *; //Date neededimport PrintWriter;public class NotePad extends JFrame{ JTextArea jta; class newl implements ActionListener { public void actionPerformed(ActionEvent e) { setText(""); } } class openl implements ActionListener { public void actionPerformed(ActionEvent e) { JFileChooser jf=new JFileChooser(); showOpenDialog(NotePhis); } } //保存文件的监听 class savel implements ActionListener { public void actionPerformed(ActionEvent e) { JFileChooser jf = new JFileChooser(); showSaveDialog(NotePhis); } } //打印的监听 ? class printl implements ActionListener { public void actionPerformed(ActionEvent e) { // PrintWriter p = new PrintWriter(NotePhis); } } //退出记事本的监听 class exitl implements ActionListener { public void actionPerformed(ActionEvent e) { Sxit(0);//退出 } } //拷贝的监听 class copyl implements ActionListener { public void actionPerformed(ActionEvent e) { py(); } } //粘贴的监听 class pastel implements ActionListener { public void actionPerformed(ActionEvent e) { paste(); } } //剪切的监听 class cutl implements ActionListener { public void actionPerformed(ActionEvent e) { ut(); } } //查找的监听 //添加日期的监听 class datel implements ActionListener { public void actionPerformed(ActionEvent e) { Date d=new Date(); append(String()); } }//构造函数 public NotePad() { jta=new JTextArea("",24,40); JScrollPane jsp=new JScrollPane(jta); JMenuBar jmb=new JMenuBar(); JMenu mFile=new JMenu("File"); JMenu mEdit=new JMenu("Edit"); JMenuItem mNew=new JMenuItem("New",KeyEVK_N); mNaddActionListener(new newl()); mFadd(mNew); JMenuItem mOpen=new JMenuItem("Open",KeyEVK_O); mOaddActionListener(new openl()); mFadd(mOpen); JMenuItem mSave=new JMenuItem("Save"); mSaddActionListener(new savel()); mFadd(mSave); mFaddSeparator(); //添加分割线 JMenuItem mPrint = new JMenuItem("Print"); mPaddActionListener(new printl()); mFadd(mPrint); mFaddSeparator(); //添加分割线 JMenuItem mExit=new JMenuItem("Exit"); mEaddActionListener(new exitl()); mFadd(mExit); mFsetMnemonic(KeyEVK_F); //编辑菜单的子菜单的处理 JMenuItem jmi; jmi=new JMenuItem("Copy"); addActionListener(new copyl()); mEadd(jmi); jmi=new JMenuItem("Cut"); addActionListener(new cutl()); mEadd(jmi); jmi=new JMenuItem("Paste"); addActionListener(new pastel()); mEadd(jmi); mEaddSeparator(); //添加分割线 jmi=new JMenuItem("Find"); mEadd(jmi); jmi=new JMenuItem("FindNext"); mEadd(jmi); mEaddSeparator(); jmi=new JMenuItem("Select All"); mEadd(jmi); jmi=new JMenuItem("Date/Time"); addActionListener(new datel()); mEadd(jmi); add(mFile); add(mEdit); setJMenuBar(jmb); ContentPane()add(jsp); setSize(200,200); setVisible(true); } //主函数,程序入口点 public static void main(String s[]) { new NotePad(); } }