(完整版)JAVA记事本源代码毕业设计论文
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
JAVA记事本源代码
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import java.io.*;
import javax.swing.undo.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.datatransfer.*;
import java.util.List;
public class Notepad4 extends JFrame implements ActionListener, DocumentListener {
JMenu mFile, mEdit, mMode, mView, mHelp;
---文件菜单
JMenuItem mFile_New, mFile_Open, mFile_Save, mFile_ASave, mFile_Print, mFile_Exit;
---编辑菜单
JMenuItem mEdit_Undo, mEdit_Cut, mEdit_Copy, mEdit_Paste, mEdit_Del,
mEdit_Search, mEdit_SearchNext, mEdit_Replace, mEdit_Turnto, mEdit_SelectAll, mEdit_TimeDate;
---格式菜单
JCheckBoxMenuItem formatMenu_LineWrap;
JMenu formatMenu_Color;
JMenuItem formatMenu_Font, formatMenu_Color_FgColor, formatMenu_Color_BgColor;
---查看菜单
JCheckBoxMenuItem viewMenu_Status;
---帮助菜单
JMenuItem mHelp_HelpTopics, mHelp_About;
---弹出菜单级菜单项
JPopupMenu popupMenu;
JMenuItem popupMenu_Undo, popupMenu_Cut, popupMenu_Copy, popupMenu_Paste, popupMenu_Delete, popupMenu_SelectAll;
---工具栏按钮
JButton newButton, openButton, saveButton, saveAsButton, printButton, undoButton, redoButton, cutButton, copyButton, pasteButton, deleteButton, searchButton, timeButton, fontButton, boldButton,
italicButton, fgcolorButton, bgcolorButton, ;
文本编辑区域
static JTextArea Text;
状态栏标签
JLabel statusLabel1, statusLabel2, statusLabel3;
JToolBar statusBar;
---系统剪贴板
Toolkit toolKit = Toolkit.getDefaultToolkit();
Clipboard clipBoard = toolKit.getSystemClipboard();
---创建撤消操作管理器
protected UndoManager undo = new UndoManager();
protected UndoableEditListener undoHandler = new UndoHandler();
----其它变量
boolean isNewFile = true; 是否新文件(未保存过的)
File currentFile; 当前文件名
String oldValue; 存放编辑区原来的内容,用于比较文本是否有改动
JButton fontOkButton; 字体设置里的"确定"按钮
----设置编辑区默认字体
protected Font defaultFont = new Font("宋体", Font.PLAIN, 12); GregorianCalendar time = new GregorianCalendar();
int = time.get(Calendar.MINUTE);
int second = time.get(Calendar.SECOND);
File saveFileName = null, fileName = null;
public Notepad4() {
super("VXBB的记事本");
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
Container container = getContentPane();
System.out.println(Text.getDragEnabled()); 支持自动拖放
JScrollPane scroll = new JScrollPane(Text);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALW AYS);