使用了简单的JFrame窗口,在窗口中添加菜单,菜单选项,点击鼠标右键出现右键菜单,用io流将输入文本域的内容保存。并设置热键alt+x为退出的热键
public class MyNotepad extends JFrame{
//菜单栏
private JMenuBar jmb = new JMenuBar();
//菜单
private JMenu jmFile = new JMenu("文件(F)");
private JMenu jmEdit = new JMenu("编辑(E)");
private JMenu jmFormat = new JMenu("格式(O)");
private JMenu jmFind = new JMenu("查看(V)");
private JMenu jmHelp = new JMenu("帮助(H)");
//菜单项
private JMenuItem jmiNew = new JMenuItem("新建");
private JMenuItem jmiOpen = new JMenuItem("打开");
private JMenuItem jmiSave = new JMenuItem("保存");
private JMenuItem jmiOther = new JMenuItem("另存为");
private JMenuItem jmiExit = new JMenuItem("退出(X)");
private JCheckBoxMenuItem jmiAutoLine = new JCheckBoxMenuItem("自动换行");
private JMenuItem jmiFont = new JMenuItem("字体");
private JFileChooser jfc = new JFileChooser();
private JTextArea jta = new JTextArea();
private JScrollPane jsp = new JScrollPane(jta);
//上下文菜单
private JPop