·Sun Java 认证介绍
·Sun开源Java平台
·Java关于对Vector的一点理解
·java中List的删除注意事项
·全国计算机等级考试二级Java考试大纲
·Java vs PHP,二者的同异
·JAVA,TOMCAT,JSP,SERVLET,JAVABEAN测
·java连接常见数据库的8类连接字符串
·java---zip 压缩成zip格式
·比较数组中元素是否相等(java)-Has
·通过JSP调用Java Bean动态生成柱状图
·Linux,Windows下执行java应用程序的
·用ActiveX操作客户端的目录,文件
·通过java实现统计单词组个数和标点符
·关于java匿名内部类,参数必须是fina
·java字串类型转换成日期类型
·java 对所有文件的操作
·如何打开java中的.class文件
 
 
 

我写的JAVA记事本

日期:2007年07月02日 23:05:46 作者:java 关键字:java游戏下载

本页内容为:我写的JAVA记事本,该文章本站转载自网络,如有侵权请告之,我们将会及时将其删除,其正文内容如下:

package untitled1;

import javax.swing.JFrame;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import javax.swing.JTextArea;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JCheckBoxMenuItem;
import java.awt.FileDialog;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.*;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.event.UndoableEditListener;
import javax.swing.event.UndoableEditEvent;
import javax.swing.undo.UndoManager;
import javax.swing.undo.*;
import javax.swing.text.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.*;
import javax.swing.JTextField;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Container;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import javax.swing.JScrollPane;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Notebook extends JFrame implements ActionListener,UndoableEditListener{
    JTextArea jTextArea = new JTextArea();//文本编辑域
    JMenuBar jMenuBar = new JMenuBar();//菜单栏
    JMenu jMenuF = new JMenu("文件(F)");//文件菜单
    JMenu jMenuE = new JMenu("编辑(E)");//编辑菜单
    JMenu jMenuO = new JMenu("格式(O)");//格式菜单
    JMenu jMenuV = new JMenu("查看(V)");//查看菜单
    JMenu jMenuH = new JMenu("帮助(H)");//帮助菜单
    //文件菜单子菜单项
    JMenuItem jFnew = new JMenuItem("新建(N)");


    JMenuItem jFopen = new JMenuItem("打开(O)");
    JMenuItem jFsave = new JMenuItem("保存(S)");
    JMenuItem jFsaveAs = new JMenuItem("另存为(A)");
    JMenuItem jFset = new JMenuItem("页面设置(U)");
    JMenuItem jFprint = new JMenuItem("打印(P)");
    JMenuItem jFexit = new JMenuItem("退出(X)");
    //编辑菜单子菜单项
    JMenuItem jEundo = new JMenuItem("撤销(U)");
    JMenuItem jEcut = new JMenuItem("剪切(T)");
    JMenuItem jEcopy = new JMenuItem("复制(C)");
    JMenuItem jEpaste = new JMenuItem("粘贴(P)");
    JMenuItem jEdel = new JMenuItem("删除(L)");
    JMenuItem jEfind = new JMenuItem("查找(F)");
    JMenuItem jEfindNext = new JMenuItem("查找下一个(N)");

    JMenuItem jEreplace = new JMenuItem("替换(R)");
    JMenuItem jEgoto = new JMenuItem("转到(G)");
    JMenuItem jEselectAll = new JMenuItem("全选(A)");
    JMenuItem jEdata = new JMenuItem("日期/时间(D)");
    //格式菜单子菜单项
    JCheckBoxMenuItem jCheckBoxMenuItem = new JCheckBoxMenuItem("自动换行", true);
    JMenuItem jOfont = new JMenuItem("字体(F)");
    //查看菜单子菜单项
    JMenuItem jVbar = new JMenuItem("状态栏(S)");
    //帮助菜单子菜单项
    JMenuItem jHhelp = new JMenuItem("帮助主题(H)");
    JMenuItem jHabout = new JMenuItem("关于记事本(A)");

    int iFrameWidth = 600;//记事本宽
    int iFrameHeight = 400;//记事本高

    String srcCurFile = null;//当前编辑文件
    String strFileContext = this.jTextArea.getText();//当前文件内容

    int fontstyle = 0;//字形
    int fontsize = 0;//字体大小

    UndoManager undoManager = new UndoManager();//撤销管理器

    int iStart = 0;//查找起始位置
    int iEnd = 0;//查找结束位置

    String strFind = null;//查找的字符串

    JScrollPane jScrollPane = new JScrollPane(this.jTextArea);//滚动条

    public Notebook()
    {
        this.jMenuBar.add(this.jMenuF);
        this.jMenuBar.add(this.jMenuE);
        this.jMenuBar.add(this.jMenuO);
        this.jMenuBar.add(this.jMenuV);
        this.jMenuBar.add(this.jMenuH);

        this.jMenuF.add(this.jFnew);
        this.jMenuF.add(this.jFopen);
        this.jMenuF.add(this.jFsave);
        this.jMenuF.add(this.jFsaveAs);
        this.jMenuF.addSeparator();
        this.jMenuF.add(this.jFset);
        this.jMenuF.add(this.jFprint);
        this.jFset.setEnabled(false);
        this.jFprint.setEnabled(false);
        this.jMenuF.addSeparator();
        this.jMenuF.add(this.jFexit);

        this.jFnew.addActionListener(this);
        this.jFopen.addActionListener(this);
        this.jFsave.addActionListener(this);
        this.jFsaveAs.addActionListener(this);
        this.jFset.addActionListener(this);
        this.jFprint.addActionListener(this);
        this.jFexit.addActionListener(this);

        this.jMenuE.add(this.jEundo);
        this.jMenuE.addSeparator();
        this.jMenuE.add(this.jEcut);
        this.jMenuE.add(this.jEcopy);
        this.jMenuE.add(this.jEpaste);
        this.jMenuE.add(this.jEdel);
        this.jMenuE.addSeparator();
        this.jMenuE.add(this.jEfind);
        this.jMenuE.add(this.jEfindNext);
        this.jMenuE.add(this.jEreplace);
        this.jMenuE.add(this.jEgoto);
        this.jEgoto.setEnabled(false);
        this.jMenuE.addSeparator();
        this.jMenuE.add(this.jEselectAll);
        this.jMenuE.add(this.jEdata);

        this.jEundo.addActionListener(this);
        this.jEcut.addActionListener(this);
        this.jEcopy.addActionListener(this);
        this.jEpaste.addActionListener(this);
        this.jEdel.addActionListener(this);
        this.jEfind.addActionListener(this);
        this.jEfindNext.addActionListener(this);
        this.jEreplace.addActionListener(this);
        this.jEgoto.addActionListener(this);
        this.jEselectAll.addActionListener(this);
        this.jEdata.addActionListener(this);

        this.jMenuO.add(this.jCheckBoxMenuItem);
        this.jMenuO.add(this.jOfont);

        this.jCheckBoxMenuItem.addActionListener(this);
        this.jOfont.addActionListener(this);

        this.jMenuV.add(this.jVbar);
        this.jVbar.addActionListener(this);
        this.jVbar.setEnabled(false);

        this.jMenuH.add(this.jHhelp);
        this.jMenuH.addSeparator();
        this.jMenuH.add(this.jHabout);
        this.jHhelp.setEnabled(false);

        this.jHhelp.addActionListener(this);
        this.jHabout.addActionListener(this);
        //可以自动换行
        this.jTextArea.setLineWrap(true);
        this.jTextArea.setWrapStyleWord(true);

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        this.setLocation((screenSize.width-this.iFrameWidth)>>1,
                         (screenSize.height-this.iFrameHeight)>>1);//设置记事本在屏幕中央显示
        this.setJMenuBar(this.jMenuBar);
        this.setTitle("无标题 - 记事本");
        this.getContentPane().add(this.jScrollPane);
        this.setSize(this.iFrameWidth,this.iFrameHeight);
        this.setVisible(true);
        this.jTextArea.getDocument().addUndoableEditListener(this);//撤销侦听


        this.addWindowListener(
                new WindowAdapter()
                { //点X关闭窗口
                    public void windowClosing(WindowEvent e)
                    {
                        System.exit(0);
                    }
                }
        );
    }
    /**
     * 程序入口
     * @param args String[]
     */
    public static void main(String[] args)
    {
        new Notebook();
    }
    /**
     * 菜单状态侦听处理
     * @param e ActionEvent
     */
    public void actionPerformed(ActionEvent e)
    {
        if(e.getActionCommand().equals("新建(N)"))
        {
            this.jTextArea.setText("");
        }
        else if(e.getActionCommand().equals("打开(O)"))
        {
            FileDialog fileDialog = new FileDialog(this,"打开一个文件",FileDialog.LOAD);
            fileDialog.setVisible(true);
            String strPath = fileDialog.getDirectory();
            String strFileName = fileDialog.getFile();
            if(strPath != null || strFileName != null)
            {
                try
                {
                    BufferedReader bufferReader = new BufferedReader(new
                            FileReader(strPath + strFileName));
                    this.jTextArea.setText("");
                    String str = "";
                    try
                    {
                        str = bufferReader.readLine();
                        while (str != null)


                        {
                            this.jTextArea.setText(str + "\n");
                            str = bufferReader.readLine();
                        }
                    }
                    catch (IOException ex1)
                    {
                        ex1.printStackTrace();
                    }
                    finally
                    {
                        try
                        {
                            bufferReader.close();
                        }

                        catch (IOException ex2)
                        {
                            ex2.printStackTrace();
                        }
                    }
                }
                catch (FileNotFoundException ex)
                {
                    ex.printStackTrace();
                }
            }
        }
        else if(e.getActionCommand().equals("保存(S)"))
        {
            this.save();
        }
        else if(e.getActionCommand().equals("另存为(A)"))
        {
            FileDialog fileDialog = new FileDialog(this,"保存一个文件",FileDialog.SAVE);
            fileDialog.setFile("*.txt");


            fileDialog.setVisible(true);
            String strPath = fileDialog.getDirectory();
            String strFileName = fileDialog.getFile();
            if (strFileName != null)
            {
                try
                {
                    PrintWriter printWriter = new PrintWriter(new
                            BufferedWriter(new FileWriter(strPath + strFileName)));


                    printWriter.write(this.jTextArea.getText(), 0,
                                      this.jTextArea.getText().length());
                    printWriter.flush();
                    printWriter.close();
                }
                catch (IOException ex4)
                {


                    ex4.printStackTrace();
                }
            }
        }
        else if(e.getActionCommand().equals("页面设置(U)"))
        {
        }
        else if(e.getActionCommand().equals("打印(P)"))
        {
        }
        else if(e.getActionCommand().equals("退出(X)"))
        {
            String strFileContext = this.jTextArea.getText();


            if(!strFileContext.equals(this.strFileContext))
            {//文件内容被改变
                int iResult = JOptionPane.showConfirmDialog(null, "文件内容已改变,确认保存退出吗?", "警告", 1);
                if(iResult == JOptionPane.OK_OPTION)
                {
                    this.save();
                    System.exit(0);
                }
                else if(iResult == JOptionPane.NO_OPTION)

                {
                    System.exit(0);
                }
            }
            else
            {
                System.exit(0);
            }
        }
        else if(e.getActionCommand().equals("撤销(U)"))
        {
            this.undoManager.undo();
        }
        else if(e.getActionCommand().equals("剪切(T)"))
        {
            this.jTextArea.cut();
        }
        else if(e.getActionCommand().equals("复制(C)"))
        {
            this.jTextArea.copy();
        }
        else if(e.getActionCommand().equals("粘贴(P)"))
        {
            this.jTextArea.paste();
        }
        else if(e.getActionCommand().equals("删除(L)"))
        {
            this.jTextArea.replaceSelection("");
        }
        else if(e.getActionCommand().equals("查找(F)"))
        {
            this.find();
        }
        else if(e.getActionCommand().equals("查找下一个(N)"))
        {
            if(this.strFind == null)
                this.find();
            else
            {
                String strText = jTextArea.getText();
                iStart = strText.indexOf(strFind,iEnd);
                iEnd = iStart + strFind.length();
                if(iStart == -1)
                    JOptionPane.showMessageDialog(null,"没不到"+strFind,"记事本",JOptionPane.WARNING_MESSAGE);
               jTextArea.select(iStart,iEnd);
            }
        }
        else if(e.getActionCommand().equals("替换(R)"))


        {
            final JDialog jDialog = new JDialog();
            jDialog.setTitle("替换");
            JLabel jLabelF = new JLabel("查找的内容");
            JLabel jLabelC = new JLabel("替换的内容");
            final JTextField jTextFieldF  = new JTextField(5);
            final JTextField jTextFieldC = new JTextField(5);
            JButton buttonFind = new JButton("查找下一个");
            buttonFind.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e) {

                    String strFindText = jTextFieldF.getText();
                    String strChangeText = jTextFieldC.getText();
                    String strText = jTextArea.getText();
                    iStart = strText.indexOf(strFindText,iEnd);
                    iEnd = iStart + strFindText.length();
                    if(iStart == -1)
                        JOptionPane.showMessageDialog(null,"没不到"+strFindText,"记事本",JOptionPane.WARNING_MESSAGE);

               jTextArea.select(iStart,iEnd);
           }
            });
            JButton buttonChange = new JButton("替换");
            buttonChange.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e) {
                    String strFindText = jTextFieldF.getText();
                    String strChangeText = jTextFieldC.getText();
                    String strText = jTextArea.getText();
                    iStart = strText.indexOf(strFindText,iEnd);
                    iEnd = iStart + strFindText.length();
                    if(iStart == -1)
                    {
                        JOptionPane.showMessageDialog(null, "没不到" + strFindText,
                                "记事本", JOptionPane.WARNING_MESSAGE);
                        jDialog.setVisible(false);
                        jDialog.dispose();
                        return;
                    }
                    jTextArea.select(iStart,iEnd);
                    jTextArea.replaceSelection(strChangeText);
                }
            });

            JButton buttonChangeAll  = new JButton("替换全部");
            buttonChangeAll.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e) {
                    String strFindText = jTextFieldF.getText();
                    String strChangeText = jTextFieldC.getText();
                    String strText = jTextArea.getText();
                    while(iStart > -1){
                        iStart = strText.indexOf(strFindText, iEnd);
                        if(iStart == -1)
                            break;
                        iEnd = iStart + strFindText.length();
                        jTextArea.select(iStart, iEnd);
                        jTextArea.replaceSelection(strChangeText);


                    }
                    iStart = 0;
                    iEnd = 0;
                    jDialog.setVisible(false);
                    jDialog.dispose();
                }
            });
            JButton buttonCancel  = new JButton("取消");
            buttonCancel.addActionListener(new ActionListener(){

                public void actionPerformed(ActionEvent e)
                {
                    jDialog.setVisible(false);
                    jDialog.dispose();
                }
            });
            JCheckBox box = new JCheckBox("区分大小写");
            GridBagLayout gbl = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            jDialog.getContentPane().setLayout(gbl);
            gbc.gridx = 0;
            gbc.gridy = 0;
            jDialog.getContentPane().add(jLabelF,gbc);
            gbc.gridx = 0;
            gbc.gridy = 1;
            jDialog.getContentPane().add(jLabelC,gbc);
            gbc.gridx = 1;
            gbc.gridy = 0;
            jDialog.getContentPane().add(jTextFieldF,gbc);
            gbc.gridx = 1;


            gbc.gridy = 1;
            jDialog.getContentPane().add(jTextFieldC,gbc);
            gbc.gridx = 2;
            gbc.gridy = 0;
            jDialog.getContentPane().add(buttonFind,gbc);
            gbc.gridx = 2;
            gbc.gridy = 1;
            jDialog.getContentPane().add(buttonChange,gbc);
            gbc.gridx = 2;
            gbc.gridy = 2;
            jDialog.getContentPane().add(buttonChangeAll,gbc);

            gbc.gridx = 2;
            gbc.gridy = 3;
            jDialog.getContentPane().add(buttonCancel,gbc);
            gbc.gridx = 0;
            gbc.gridy = 2;
            jDialog.getContentPane().add(box,gbc);
            jDialog.setSize(400,200);
            jDialog.setLocation(400,200);
            jDialog.setVisible(true);

        }
        else if(e.getActionCommand().equals("转到(G)"))
        {
            final JFrame frame = new JFrame("转到下列行");
            final JTextField field = new JTextField(10);
            field.setSize(100,50);
            JLabel label = new JLabel("转到的行数");
            JButton ok = new JButton("确定");
            ok.addActionListener(new ActionListener()
            {
              public void actionPerformed(ActionEvent e)


              {
                frame.dispose();
              }
            });
            JButton cancel = new JButton("取消");
            GridBagLayout gbl = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            frame.getContentPane().setLayout(gbl);
            gbc.gridx = 0;
            gbc.gridy = 0;
            frame.getContentPane().add(label,gbc);
            gbc.gridx = 1;
            gbc.gridy = 0;
            frame.getContentPane().add(field,gbc);
            gbc.gridx = 0;
            gbc.gridy = 1;
            frame.getContentPane().add(ok,gbc);
            gbc.gridx = 2;
            gbc.gridy = 1;
            frame.getContentPane().add(cancel,gbc);
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Dimension screenSize = toolkit.getScreenSize();

            frame.setLocation((screenSize.width-this.iFrameWidth)>>1,
                             (screenSize.height-this.iFrameHeight)>>1);
            frame.setSize(300,100);
            frame.setVisible(true);
        }
        else if(e.getActionCommand().equals("全选(A)"))
        {
            this.jTextArea.selectAll();
        }
        else if(e.getActionCommand().equals("日期/时间(D)"))
        {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm yyyy-M-d");
            this.jTextArea.insert(simpleDateFormat.format(new Date()),
                                  this.jTextArea.getCaretPosition());
        }
        else if(e.getActionCommand().equals("自动换行"))
        {
            if(this.jCheckBoxMenuItem.getState())
            {
                this.jTextArea.setLineWrap(true);
                this.jTextArea.setWrapStyleWord(true);
            }
            else
            {
                this.jTextArea.setLineWrap(false);
                this.jTextArea.setWrapStyleWord(false);
            }
        }
        else if(e.getActionCommand().equals("字体(F)"))
        {
            final JDialog jDialog = new JDialog();
            final JTextField jtf2 = new JTextField(6);
            final JTextField jtf3 = new JTextField(3);
            final JTextField jtf1 = new JTextField(6);
            JButton jButtonOk = new JButton("确定");
            JButton jButtonExit = new JButton("取消");
            final JComboBox jComboBox = new JComboBox();
            jComboBox.addItem("BOLD");
            jComboBox.addItem("ITALIC");
            jComboBox.addItem("PLAIN");
            jComboBox.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jtf2.setText((String) jComboBox.getSelectedItem());
                    if(jComboBox.getSelectedItem().equals("BOLD"))
                    {
                        fontstyle = 1;
                    }
                    else if(jComboBox.getSelectedItem().equals("ITALIC"))


                    {
                        fontstyle = 2;
                    }
                    else if(jComboBox.getSelectedItem().equals("PLAIN"))
                    {
                        fontstyle = 0;
                    }
                }
            });
            final JComboBox jComboBoxFontSize = new JComboBox();
            jComboBoxFontSize.addItem("14");
            jComboBoxFontSize.addItem("18");
            jComboBoxFontSize.addItem("22");

            jComboBoxFontSize.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jtf3.setText((String) jComboBoxFontSize.getSelectedItem());
                    if(jComboBoxFontSize.getSelectedItem().equals("14"))
                   {
                       fontsize = 14;
                   }
                   else if(jComboBoxFontSize.getSelectedItem().equals("18"))
                   {
                       fontsize = 18;
                   }
                   else if(jComboBoxFontSize.getSelectedItem().equals("22"))
                   {
                       fontsize = 22;
                   }

                }

            });
            final JComboBox jComboBoxFont = new JComboBox();
            jComboBoxFont.addItem("宋体");
            jComboBoxFont.addItem("黑体");
            jComboBoxFont.addItem("美体");
            jComboBoxFont.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jtf1.setText((String) jComboBoxFont.getSelectedItem());
                }
            });
            JLabel jl1 = new JLabel("字体:");
            JLabel jl2 = new JLabel("字形:");
            JLabel jl3 = new JLabel("大小:");
            GridBagLayout gbl = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            jDialog.getContentPane().setLayout(gbl);
            gbc.gridx = 5;
            gbc.gridy = 2;
            jDialog.getContentPane().add(jButtonOk, gbc);


            gbc.gridx = 5;
            gbc.gridy = 3;
            jDialog.getContentPane().add(jButtonExit, gbc);
            gbc.gridx = 1;
            gbc.gridy = 3;
            jDialog.getContentPane().add(jComboBox, gbc);
            gbc.gridx = 2;
            gbc.gridy = 3;
            jDialog.getContentPane().add(jComboBoxFontSize, gbc);
            gbc.gridx = 0;
            gbc.gridy = 3;


            jDialog.getContentPane().add(jComboBoxFont, gbc);
            gbc.gridx = 1;
            gbc.gridy = 2;
            jDialog.getContentPane().add(jtf2, gbc);
            gbc.gridx = 2;
            gbc.gridy = 2;
            jDialog.getContentPane().add(jtf3, gbc);
            gbc.gridx = 1;
            gbc.gridy = 1;
            jDialog.getContentPane().add(jl2, gbc);
            gbc.gridx = 2;

            gbc.gridy = 1;
            jDialog.getContentPane().add(jl3, gbc);
            gbc.gridx = 0;
            gbc.gridy = 1;
            jDialog.getContentPane().add(jl1, gbc);
            gbc.gridx = 0;
            gbc.gridy = 2;
            jDialog.getContentPane().add(jtf1, gbc);

            jButtonOk.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    if(e.getActionCommand().equals("确定"))
                    {
                        Font f = new Font("字体设置", fontstyle, fontsize);
                        jTextArea.setFont(f);
                        jDialog.dispose();
                    }
                }
            });
            jButtonExit.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    if(e.getActionCommand().equals("取消"))
                    {
                        jDialog.dispose();
                    }


                }
            });
            jDialog.setSize(400, 200);
            jDialog.setLocation(240, 200);
            jDialog.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jDialog.setVisible(true);
        }
        else if(e.getActionCommand().equals("状态栏(S)"))
        {
            JLabel labelX = new JLabel(String.valueOf(this.jTextArea.getRows()));
            JLabel labelY = new JLabel(String.valueOf(this.jTextArea.getColumns()));
            labelX.setVisible(true);
            labelY.setVisible(true);
        }
        else if(e.getActionCommand().equals("帮助主题(H)"))
        {

        }
        else if(e.getActionCommand().equals("关于记事本(A)"))
        {
           JOptionPane.showMessageDialog(null, "sld开发得java记事本程序,可供学习参考。",
                                          "警告",JOptionPane.INFORMATION_MESSAGE);
        }
  }

    /**
     * 可撤消的编辑操作记录器
     * @param e UndoableEditEvent
     */
    public void undoableEditHappened(UndoableEditEvent e)
    {
        this.undoManager.addEdit(e.getEdit());
    }

    /**
     * 保存文件方法
     */
    private void save()
    {
        FileDialog fileDialog = null;
        String strPath = "";
        String strFileName = "";

        if(this.srcCurFile != null)
        {//文件已保存过
            File file = new File(this.srcCurFile);
          &n


 
 
如果你对本文我写的JAVA记事本有意见或看法,请点此留言