- //文件菜单,子菜单
- private JMenu mFile = new JMenu("文件(F)");
- private JMenuItem itNew = new JMenuItem("新建(N)");
setJMenuBar(myJmb);//菜单栏
myJmb.add(mFile);//子菜单
mFile.setMnemonic('F');//添加加速器
mFile.add(itNew);
itNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,InputEvent.CTRL_MASK));//添加快捷键
itNew.setMnemonic('N');
itNew.addActionListener(this);//添加事件响应