一个简单的记事本代码(一)
时间:2011-01-11
import java.awt.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.lang.*;
import java.text.*;
import java.io.*;
import java.util.*;
import javax.accessibility.*;
import java.awt.datatransfer.*;
// 课设 记事本
/**********************************************************/
public class Notepad extends JFrame implements ActionListener,MouseListener
{
JPanel contentPane;
JMenuBar jMenuBar1 = new JMenuBar();
//工具条
JToolBar toolBar = new JToolBar();
JButton button1=new JButton(new ImageIcon("new.gif"));
JButton button2=new JButton(new ImageIcon("open.gif"));
JButton button3=new JButton(new ImageIcon("save.gif"));
//文件菜单
JMenu jMenuFile = new JMenu();
JMenuItem jMenuFileNew = new JMenuItem();
JMenuItem jMenuFileOpen = new JMenuItem();
JMenuItem jMenuFileSave = new JMenuItem();
JMenuItem jMenuFileSaveTo = new JMenuItem();
JMenuItem jMenuFileExit = new JMenuItem();
//帮助菜单
JMenu jMenuHelp = new JMenu();
JMenuItem jMenuHelpAbout = new JMenuItem();
BorderLayout borderLayout1 = new BorderLayout();
//编辑菜单
JMenu jMenuFileEdit = new JMenu();
JMenuItem jMenuFileCut = new JMenuItem();
JMenuItem jMenuFileCopy = new JMenuItem();
JMenuItem jMenuFilePaste = new JMenuItem();
JMenuItem jMenuFileDel = new JMenuItem();
//右键菜单
JMenuItem jMenuMouseCut = new JMenuItem("剪切");
JMenuItem jMenuMouseCopy = new JMenuItem("复制");
JMenuItem jMenuMousePaste = new JMenuItem("粘贴");
JMenuItem jMenuMouseDel = new JMenuItem("删除");
//格式菜单
JMenu jMenuFileForm = new JMenu();
JMenuItem jMenuFileFindNext = new JMenuItem();
JMenuItem jMenuFileSelect=new JMenuItem("全选");
JMenuItem jMenuFileTime = new JMenuItem("时间/日期(D)");
// JMenuItem jMenuFileLine = new JMenuItem("自动换行");
JMenuItem jMenuFileFont = new JMenuItem();
JMenuItem jcolor=new JMenuItem("颜色...");
JCheckBox jMenuCheckBox = new JCheckBox("自动换行",true);
JTextArea jTextArea1 = new JTextArea(15,15);
JLabel statubar=new JLabel("状态栏");
JPopupMenu pm=new JPopupMenu();
Calendar cal=Calendar.getInstance();
// 变量声明
String filename;
String filepath;
String strtext="";
boolean bsaved = false;
JFileChooser jFileChooser = new JFileChooser();
JColorChooser jColor=new JColorChooser();
FileDialog filedialog_save;
BufferedWriter out;
FileWriter tofile;
Clipboard cb=Toolkit.getDefaultToolkit().getSystemClipboard();
int n;
int i;
int t;
boolean check=true;
FileDialog dog;
/**********************************************************/
//组件初始化
public Notepad(){
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setBounds(110,100,500, 450);
this.setFont(new Font("宋体", Font.PLAIN, 8));
this.setTitle("记事本");
jTextArea1.setDoubleBuffered(false);
jTextArea1.setToolTipText("记事本");
jTextArea1.setVerifyInputWhenFocus
|