欢迎来到天天文库
浏览记录
ID:37852329
大小:131.00 KB
页数:26页
时间:2019-06-01
《java记事本源码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、packagecom.java.notepad;importjavax.swing.*;importjavax.swing.border.Border;importjavax.swing.event.MenuEvent;importjavax.swing.event.MenuListener;importjavax.swing.event.UndoableEditEvent;importjavax.swing.event.UndoableEditListener;importjavax.swing.filechooser.FileFilter;import
2、java.awt.*;importjava.awt.datatransfer.Clipboard;importjava.awt.datatransfer.DataFlavor;importjava.awt.datatransfer.Transferable;importjava.awt.event.*;importjava.io.BufferedReader;importjava.io.BufferedWriter;importjava.io.File;importjava.io.FileNotFoundException;importjava.io.Fi
3、leReader;importjava.io.FileWriter;importjava.io.IOException;importjava.util.Vector;importjavax.swing.JDialog;importjavax.swing.undo.UndoManager;/***记事本*@authorWMeng*@version1.02012.08.15**/publicclassNotePad{publicstaticvoidmain(String[]args){NotePadFrameframe=newNotePadFrame();fr
4、ame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);//frame.textArea.requestFocus();frame.textArea.requestFocusInWindow();}}classNotePadFrameextendsJFrame{publicNotePadFrame(){init();}publicNotePadFrame(intx,inty){this.setLocation(x,y);init();}JTextAreatextAr
5、ea=newJTextArea(15,50);JScrollPanescrollPane;JPopupMenupopupmenu;booleanisSave=false;privatevoidinit(){finalUndoManagermanager=newUndoManager();textArea.getDocument().addUndoableEditListener(newUndoableEditListener(){publicvoidundoableEditHappened(UndoableEditEvente){manager.addEd
6、it(e.getEdit());}});//设置窗体观感Stringplaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";try{UIManager.setLookAndFeel(plaf);SwingUtilities.updateComponentTreeUI(this);}catch(ClassNotFoundExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(InstantiationException
7、e){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(IllegalAccessExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(UnsupportedLookAndFeelExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}//UIManager.LookAndFeelInfo[]infos=UIManager.getInstal
8、ledLookAndFeels();//for(UIManager
此文档下载收益归作者所有