资源描述:
/** * 作品记事本 * 作者*** * 功能简单的文字编辑 */ import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; class NotePad extends JFrame{ private JMenuBar menuBar; private JMenu fielMenu,editMenu,Menu,aboutMenu; private JMenuItem newMenuItem,openMenuItem,saveMenuItem,exitMenuItem; private JMenuItem cutMenuItem,copyMenuItem,pasteMenuItem,foundItem,replaceItem,selectAll; private JMenuItem font,about; private JTextArea textArea; private JFrame foundFrame,replaceFrame; private JCheckBoxMenuItem wrapline; private JTextField textField1new JTextField15; private JTextField textField2new JTextField15; private JButton startButton,replaceButton,reallButton; int start0; String value; File filenull; JFileChooser fileChoosernew JFileChooser; boolean wrapfalse; public NotePad{ //创建文本域 textAreanew JTextArea; addnew JScrollPanetextArea,BorderLayout.CENTER; //创建文件菜单及文件菜单项 fielMenunew JMenu“文件“; fielMenu.setFontnew Font“微软雅黑“,0,15; newMenuItemnew JMenuItem“新建“,new ImageIcon“icons\\new24.gif“; newMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; newMenuItem.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_N,Event.CTRL_MASK; newMenuItem.addActionListenerlistener; openMenuItemnew JMenuItem“打开“,new ImageIcon“icons\\open24.gif“; openMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; openMenuItem.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_O,Event.CTRL_MASK; openMenuItem.addActionListenerlistener; saveMenuItemnew JMenuItem“保存“,new ImageIcon“icons\\save.gif“; saveMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; saveMenuItem.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_S,Event.CTRL_MASK; saveMenuItem.addActionListenerlistener; exitMenuItemnew JMenuItem“退出“,new ImageIcon“icons\\exit24.gif“; exitMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; exitMenuItem.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_E,Event.CTRL_MASK; exitMenuItem.addActionListenerlistener; //创建编辑菜单及菜单项 editMenunew JMenu“编辑“; editMenu.setFontnew Font“微软雅黑“,0,15; cutMenuItemnew JMenuItem“剪切“,new ImageIcon“icons\\cut24.gif“; cutMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; cutMenuItem.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_X,Event.CTRL_MASK; cutMenuItem.addActionListenerlistener; copyMenuItemnew JMenuItem“复制“,new ImageIcon“icons\\copy24.gif“; copyMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; copyMenuItem.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_C,Event.CTRL_MASK; copyMenuItem.addActionListenerlistener; pasteMenuItemnew JMenuItem“粘贴“,new ImageIcon“icons\\paste24.gif“; pasteMenuItem.setFontnew Font“微软雅黑“,Font.BOLD,13; pasteMenuItem.setAcceleratorK
展开阅读全文