import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
public class note
{
public static void main(String[] args)
{
myfr fr=new myfr("JAVA记事本");
fr.setSize(560,395);
}
}
///////////////////////////myfr主窗体类//////////////////////////////////////
class myfr extends JFrame implements ActionListener
{
String str,strnext,path,fname; //部分变量的声明
JPanel mainpane;
JFileChooser choose = new JFileChooser(); //文件对话框
Dialog find,replace; //find为查找对话框,replace对话框
JTextField findtxt,repltxt; //findtxt为查找对话框的输入文本区,repltxt对话框的输入文本区
Font newfont;
JButton findenter,replb; //find为查找对话框,replace对话框的确定按钮
JLabel state=new JLabel(" JAVA记事本------未命名
文档"); //状态栏
JTextArea txt1; //主输入文本区
File newfiles;
JPopupMenu popm; //弹出菜单声明
//JMenu m1,m2,m3,m4,m5,m6; //各菜单项
JMenu m1, m2, m3;
JMenuItem m26,m271,m34,p_copy,p_cut,p_paste,p_del;
//JMenuItem m26, m271, p_copy, p_cut, p_paste, p_del;
int startp,endp,nexttemp,newstartp,newendp; //查找替换时所用的临时变量
JToolBar toolbar = new JToolBar(); //工具条
JButton newf=new JButton(new ImageIcon("pic/new.gif")); //图标在PIC下
JButton open=new JButton(new ImageIcon("pic/open.gif"));
JButton save=new JButton(new ImageIcon("pic/save.gif"));
JButton copy=new JButton(new ImageIcon("pic/copy.gif"));
JButton cut=new JButton(new ImageIcon("pic/cut.gif"));
JButton pp=new JButton(new ImageIcon("pic/pp.gif"));
JButton del=new JButton(new ImageIcon("pic/del.gif"));
JButton findc=new JButton(new ImageIcon("pic/find.gif"));
JButton count = new JButton(new ImageIcon("pic/count.gif"));
//JButton color=new JButton(new ImageIcon("pic/color.gif"));
myfr(String sss) /////构造函数开始
{
super(sss);
JMenuBar mb=new JMenuBar();
fname=null; //初始文件名为空
findenter=new JButton("确定"); //find为查找对话框,replace对话框的确定按钮
findenter.addActionListener(this); //声明对话框中上确定按钮,并注册事件
replb=new JButton("确定"); //replace对话框的确定按钮
replb.addActionListener(this);
mainpane=(JPanel)this.getContentPane();
mainpane.setLayout(new BorderLayout());
txt1=new JTextArea("",13,61);
txt1.addMouseListener(new handlemouse(this));//
注册鼠标右击事件
txt1.setFont(new Font("宋体",Font.PLAIN,18));
mainpane.add(txt1, BorderLayout.CENTER);
mainpane.add("North",toolbar);
mainpane.add("South",state);
JScrollPane sll = new JScrollPane(); //创建滚动条
mainpane.add("Center", sll); ;
sll.getViewport().add(txt1); //将滚动条装入文本区
popm=new JPopupMenu(); ////POPMeun 开始
p_copy=new JMenuItem("复制 ");
p_copy.addActionListener(this);
KeyStroke keycopyp=KeyStroke.getK
eyStroke(KeyEvent.VK_C,Event.CTRL_MASK);
p_copy.setAccelerator(keycopyp);
p_cut=new JMenuItem("剪切 ");
p_cut.addActionListener(this);
KeyStroke keycutp=KeyStroke.getKeyStroke(KeyEvent.VK_X,Event.CTRL_MASK);
p_cut.setAccelerator(keycutp);
p_paste=new JMenuItem("粘贴 ");
p_paste.addActionListener(this);
KeyStroke keypp=KeyStroke.getKeyStroke(KeyEvent.V