91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 35KB
    文件類型: .java
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-01
  • 語言: Java
  • 標(biāo)簽: 廣工??Java課設(shè)??

資源簡介

廣工java文本編輯器課設(shè)(含源代碼和報告),完成文本編輯器的基本功能新建文本、保存文本、打開文本、撤銷、刪除、剪切、復(fù)制、粘貼、大小寫轉(zhuǎn)換、查找、字?jǐn)?shù)、行數(shù)、狀態(tài)欄、字體大小和顏色、背景顏色等

資源截圖

代碼片段和文件信息

package?TextEdit;

import?javax.swing.*;
import?javax.swing.border.EmptyBorder;
import?javax.swing.event.CaretEvent;
import?javax.swing.event.CaretListener;
import?javax.swing.undo.UndoManager;

import?java.awt.*;
import?java.io.*;
import?java.awt.event.*;

public?class?TextMainframe?extends?Jframe?implements?ActionListener?{

private?static?final?long?serialVersionUID?=?1L;

private?static?Jframe?jf?=?new?Jframe();
//菜單欄
private?JMenuBar?menuBar;//菜單欄
private?JMenu?FileEditCountFormatHelp;?//菜單
private?JMenu?LUcase; //edit子項同時也有自己的子項
private?JMenuItem?newfileopenfilesavefilesaveAsfileexit;??//file的子項
private?JMenuItem?undoredocutcopypastedeleteallselectreplacesearch;//edit的子項
private?JMenuItem?wordrowcharacter; //view的子項
????private?JCheckBoxMenuItem?view; //view的子項
private?JMenuItem?font_formatfont_colorbackgound;//format的子項
????private?JCheckBoxMenuItem?autoNextLine; //format子項
private?JMenuItem?about; //help的子項
private?JMenuItem?allUpperallLowerfirstUpper; //LUcase的子項
private?JToolBar?toolState; //邊框的工具欄
public??JLabel?label1;
private?JLabel?label2;
private?JPanel?contentPane;
//撤銷管理器
????private?UndoManager?undoMgr?=?new?UndoManager();??
?
????//文本域??加入滾動條
????static?JTextArea?textArea?=?new?JTextArea();
????JScrollPane?textScrollPane?=?new?JScrollPane(textAreaJScrollPane.VERTICAL_SCROLLBAR_ALWAYS?
???? JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //水平和豎直滾動條
????
????//文本的行數(shù)和列數(shù)
????int?rowNum?=?1;
????int?columnNum?=?1;
????int?length?=?0; //文本字?jǐn)?shù)
????
????//1:新建?
????//2:修改過
????//3:保存過的
????int?flag?=?0;
?????
????static?String?filePath?=?null;?? //先讓路徑為空
????static?String?fileName?=?null;?? //先讓文件名為空
????
????Font?f1?=?new?Font(“宋體“Font.PLAIN15); //設(shè)置字體
Replace?r?=?new?Replace();? //實例化Replace類
Search?s?=?new?Search();? //實例化Search類
? font?f?=?new?font(); //實例化font類
????
????
????//主頁面構(gòu)造函數(shù)
public?TextMainframe(){

initMenuBar();??//初始化菜單欄
initListener();??//初始化監(jiān)聽器
initShortCutKey(); //初始化快捷鍵
????????this.settitle(“文本編輯器“);
???? this.setJMenuBar(menuBar);
???? this.add(textScrollPaneBorderLayout.CENTER);?//加入滾動條
? ????//設(shè)置窗口的位置大小
???? this.setSize(650?420);
???? this.setLocation(330?200);
??? ????
}??

//初始化菜單欄
public?void?initMenuBar()?{
menuBar?=?new?JMenuBar();
//File?菜單
File?=?new?JMenu(“文件(F)“);
newfile?=?new?JMenuItem(“新建(N)“);
openfile?=?new?JMenuItem(“打開(O)“);
savefile?=?new?JMenuItem(“保存(S)“);
saveAsfile?=?new?JMenuItem(“另存為(A)“);
exit?=?new?JMenuItem(“退出(X)“);
File.add(newfile); //加入子項
File.add(openfile);
File.add(savefile);
File.add(saveAsfile);
File.add(exit);
File.setFont(f1); //設(shè)置字體
newfile.setFont(f1);
openfile.setFont(f1);
savefile.setFont(f1);
saveAsfile.setFont(f1);
exit.setFont(f1);

//Edit?菜單
Edit?=?new?JMenu(“編輯(E)“);
undo?=?new?JMenuItem(“撤銷(U)“);
redo?=?new?JMenuItem(“恢復(fù)(D)“);
cut?=?new?JMenuItem(“剪切(T)“

評論

共有 條評論