九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

文本編輯器 java課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告 完整 預(yù)覽顯示不全 含全部代碼

上傳人:少*** 文檔編號(hào):67640035 上傳時(shí)間:2022-03-31 格式:DOC 頁(yè)數(shù):24 大?。?.99MB
收藏 版權(quán)申訴 舉報(bào) 下載
文本編輯器 java課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告 完整 預(yù)覽顯示不全 含全部代碼_第1頁(yè)
第1頁(yè) / 共24頁(yè)
文本編輯器 java課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告 完整 預(yù)覽顯示不全 含全部代碼_第2頁(yè)
第2頁(yè) / 共24頁(yè)
文本編輯器 java課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告 完整 預(yù)覽顯示不全 含全部代碼_第3頁(yè)
第3頁(yè) / 共24頁(yè)

下載文檔到電腦,查找使用更方便

16 積分

下載資源

還剩頁(yè)未讀,繼續(xù)閱讀

資源描述:

《文本編輯器 java課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告 完整 預(yù)覽顯示不全 含全部代碼》由會(huì)員分享,可在線閱讀,更多相關(guān)《文本編輯器 java課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告 完整 預(yù)覽顯示不全 含全部代碼(24頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、 淮 海 工 學(xué) 院 計(jì)算機(jī)工程學(xué)院課程設(shè)計(jì)報(bào)告設(shè)計(jì)名稱: 面向?qū)ο笳n程設(shè)計(jì) 選題名稱: 文本編輯器的設(shè)計(jì)與實(shí)現(xiàn) 姓 名: 學(xué) 號(hào): 專業(yè)班級(jí): 系 (院): 計(jì)算機(jī)工程學(xué)院 設(shè)計(jì)時(shí)間: 2010.6.212010.7.2 設(shè)計(jì)地點(diǎn): 軟件實(shí)驗(yàn)室、教室 成績(jī):指導(dǎo)教師評(píng)語(yǔ): 簽名: 年 月 日面向?qū)ο笳n程設(shè)計(jì)報(bào)告 第 24 頁(yè),共 24 頁(yè)1設(shè)計(jì)要求設(shè)計(jì)一個(gè)類似于Windows記事本(Notepad)的Java程序??梢源蜷_、新建、保存一個(gè)文本文件;對(duì)選中的文本進(jìn)行各種編輯操作(設(shè)置字體、字號(hào)、字型、對(duì)齊方式、背景、前景色、復(fù)制、粘貼、剪切、查找、替換等);在文本中能夠插入對(duì)象。2總體設(shè)計(jì)打開

2、保存文件另存為查找紅色退出字體顏色復(fù)制編輯藍(lán)色剪切宋體綠色文本編輯器粘貼字體仿宋楷體粗體 字形斜體常規(guī)字號(hào)3詳細(xì)設(shè)計(jì)JTextArea textarea;/建立文本 JRadioButtonMenuItem rbmi_red,rbmi_blue,rbmi_green;/鼠標(biāo)右擊改變顏色 JMenuItem menuitem_copy,menuitem_cut,menuitem_paste,menuitem_seek;/復(fù)制,剪切,粘貼 JMenuItem menuitem_song,menuitem_fang,menuitem_kai;/字體變量 JMenuItem menuitem_norm

3、al,menuitem_bold,menuitem_italic;/字形變量 JMenuItem menuitem_12,menuitem_24,menuitem_36;/字號(hào)變量 JMenuItem menuitem_exit,menuitem_infor; JPopupMenu popupmenu;/文本快捷鍵 JMenuItem menuitem_red,menuitem_green,menuitem_blue;/顏色變量 JDialog dialog;/調(diào)用對(duì)話框 JButton button_seek;/查找 JTextField textfield_seek; JLabel lab

4、el_seek,label_infor;4代碼調(diào)試程序代碼:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import javax.swing.JColorChooser;import javax.swing.event.*;public class Notepad extends JFrame implements ActionListener,ItemListener,MouseListener File file; JTextArea textarea; JRadioButt

5、onMenuItem rbmi_red,rbmi_blue,rbmi_green; JMenuItem menuitem_copy,menuitem_cut,menuitem_paste,menuitem_seek; JMenuItem menuitem_song,menuitem_fang,menuitem_kai;/字體變量 JMenuItem menuitem_normal,menuitem_bold,menuitem_italic;/字形變量 JMenuItem menuitem_12,menuitem_24,menuitem_36;/字號(hào)變量 JMenuItem menuitem_e

6、xit,menuitem_infor; JMenuItem menuitem_zidingyi; JPopupMenu popupmenu; JMenuItem menuitem_red,menuitem_green,menuitem_blue; JDialog dialog; JButton button_seek; JTextField textfield_seek; JLabel label_seek,label_infor; String seek; public Notepad() super(文本編輯器); this.setSize(600,400); this.setLocati

7、on(250,150); this.setDefaultCloseOperation(HIDE_ON_CLOSE); textarea = new JTextArea(); Container ss=this.getContentPane(); JScrollPane dd=new JScrollPane(textarea); ss.add(dd); this.textarea.addMouseListener(this); this.addMenu(); this.setVisible(true); this.Dialog(); this.file = null; public Notepa

8、d(String filename) this(); if (filename!=null) this.file = new File(filename); this.setTitle(filename); this.textarea.setText(this.readFromFile(); public Notepad(File file) this(); if (file!=null) this.file = file; this.setTitle(this.file.getName(); this.textarea.setText(this.readFromFile(); public

9、void Dialog() /建立對(duì)話框的方法 dialog=new JDialog(this,查找,true); dialog.setLayout(new FlowLayout(); dialog.setSize(200,90); label_seek=new JLabel(關(guān)鍵字); dialog.add(label_seek); textfield_seek=new JTextField(10); dialog.add(textfield_seek); button_seek=new JButton(查找); dialog.add(button_seek); button_seek.ad

10、dActionListener(this); public void addMenu() JMenuBar menubar = new JMenuBar(); this.setJMenuBar(menubar); JMenu menu_file = new JMenu(文件); /文件菜單 menubar.add(menu_file); JMenuItem menuitem_open = new JMenuItem(打開); menu_file.add(menuitem_open); menuitem_open.addActionListener(this); JMenuItem menuit

11、em_save = new JMenuItem(保存); menu_file.add(menuitem_save); menuitem_save.addActionListener(this); JMenuItem menuitem_saveas = new JMenuItem(另存為); menu_file.add(menuitem_saveas); menuitem_saveas.addActionListener(this); menuitem_exit=new JMenuItem(退出 ); menu_file.add(menuitem_exit); menuitem_exit.add

12、ActionListener(this); JMenu menu_editor=new JMenu(編輯);/編輯菜單 menubar.add(menu_editor); menuitem_seek=new JMenuItem(查找); menu_editor.add(menuitem_seek); menuitem_seek.addActionListener(this); menuitem_copy=new JMenuItem(復(fù)制); menuitem_copy.addActionListener(this); menu_editor.add(menuitem_copy); menuit

13、em_cut=new JMenuItem(剪切); menu_editor.add(menuitem_cut); menuitem_cut.addActionListener(this); menuitem_paste=new JMenuItem(粘貼); menu_editor.add(menuitem_paste); menuitem_paste.addActionListener(this); JMenuItem menu_color=new JMenu(顏色);/顏色菜單 menu_editor.add(menu_color); ButtonGroup buttongroup=new

14、ButtonGroup(); rbmi_red=new JRadioButtonMenuItem(紅,true); buttongroup.add(rbmi_red); menu_color.add(rbmi_red); rbmi_red.addItemListener(this); rbmi_blue=new JRadioButtonMenuItem(藍(lán),true); buttongroup.add(rbmi_blue); menu_color.add(rbmi_blue); rbmi_blue.addItemListener(this); rbmi_green=new JRadioButt

15、onMenuItem(綠,true); buttongroup.add(rbmi_green); menu_color.add(rbmi_green); rbmi_green.addItemListener(this); JMenu menu_font=new JMenu(設(shè)置字體);/設(shè)置字體菜單 menubar.add(menu_font); menuitem_song=new JMenuItem(宋體); menu_font.add(menuitem_song); menuitem_song.addActionListener(this); menuitem_fang=new JMenu

16、Item(仿宋); menu_font.add(menuitem_fang); menuitem_fang.addActionListener(this); menuitem_kai=new JMenuItem(楷體); menu_font.add(menuitem_kai); menuitem_kai.addActionListener(this); JMenu menu_style=new JMenu(設(shè)置字形);/設(shè)置字形菜單 menubar.add(menu_style); menuitem_bold=new JMenuItem(粗體); menu_style.add(menuitem

17、_bold); menuitem_bold.addActionListener(this); menuitem_italic=new JMenuItem(斜體); menu_style.add(menuitem_italic); menuitem_italic.addActionListener(this);menuitem_normal=new JMenuItem(常規(guī));menu_style.add(menuitem_normal);menuitem_normal.addActionListener(this); JMenu menu_size=new JMenu(設(shè)置字號(hào)); /設(shè)置字號(hào)

18、菜單 menubar.add(menu_size); menuitem_12=new JMenuItem(12); menu_size.add(menuitem_12); menuitem_12.addActionListener(this); menuitem_24=new JMenuItem(24); menu_size.add(menuitem_24); menuitem_24.addActionListener(this); menuitem_36=new JMenuItem(36); menu_size.add(menuitem_36); menuitem_36.addActionL

19、istener(this); popupmenu=new JPopupMenu(); /快捷菜單 JMenuItem menuitem_red=new JMenuItem(紅色); popupmenu.add(menuitem_red); menuitem_red.addActionListener(this); JMenuItem menuitem_green=new JMenuItem(綠色); popupmenu.add(menuitem_green); menuitem_green.addActionListener(this); menuitem_blue=new JMenuItem

20、(藍(lán)色); popupmenu.add(menuitem_blue); menuitem_blue.addActionListener(this); textarea.add(popupmenu); /向文本區(qū)內(nèi)添加快捷菜單 public void writeToFile(String lines) /寫文件 try FileWriter fout = new FileWriter(this.file); fout.write(lines+rn); fout.close(); catch (IOException ioex) return; public String readFromFile

21、() /讀文件 try FileReader fin = new FileReader(this.file); BufferedReader bin = new BufferedReader(fin); String aline=, lines=; do aline = bin.readLine(); if (aline!=null) lines += aline + rn; while (aline!=null); bin.close(); fin.close(); return lines; catch (IOException ioex) return null; public bool

22、ean openDialog() /打開對(duì)話框 FileDialog filedialog = new FileDialog(this,Open,FileDialog.LOAD); filedialog.setVisible(true); if (filedialog.getDirectory()!=null) & (filedialog.getFile()!=null) this.file = new File(filedialog.getDirectory(), filedialog.getFile(); return true; else return false; public boo

23、lean saveDialog() /保存對(duì)話框 FileDialog filedialog = new FileDialog(this,SaveAs,FileDialog.SAVE); filedialog.setFile(this.file.getName(); filedialog.setVisible(true); if (filedialog.getDirectory()!=null) & (filedialog.getFile()!=null) this.file = new File(filedialog.getDirectory(), filedialog.getFile()+

24、.txt); return true; else return false; public void actionPerformed(ActionEvent e) /事件處理 if(e.getActionCommand()=打開) if (this.openDialog() this.setTitle(this.file.getName(); this.textarea.setText(this.readFromFile(); if(e.getActionCommand()=保存 & this.file!=null) this.writeToFile(this.textarea.getText

25、(); if(e.getActionCommand()=保存 & this.file=null | e.getActionCommand()=另存為) if (this.saveDialog() this.writeToFile(this.textarea.getText(); this.setTitle(this.file.getName(); if(e.getActionCommand()=退出) System.exit(0); if(e.getSource()=menuitem_copy) /編輯菜單的事件處理 textarea.copy(); if(e.getSource()=menu

26、item_paste) textarea.paste(); if(e.getSource()=menuitem_cut) textarea.cut(); if(e.getSource()=menuitem_red) /顏色菜單的事件處理 textarea.setForeground(Color.red); if(e.getSource()=menuitem_blue) textarea.setForeground(Color.blue); if(e.getSource()=menuitem_green) textarea.setForeground(Color.green); Font fon

27、t=textarea.getFont(); /設(shè)置字體變量 int style=font.getStyle(); if(e.getSource()=menuitem_song) textarea.setFont(new java.awt.Font(宋體,java.awt.Font.PLAIN,font.getSize(); if(e.getSource()=menuitem_fang) textarea.setFont(new java.awt.Font(仿宋,java.awt.Font.PLAIN,font.getSize(); if(e.getSource()=menuitem_kai)

28、textarea.setFont(new java.awt.Font(楷體,java.awt.Font.PLAIN,font.getSize(); if(e.getSource()=menuitem_bold) /設(shè)置字形菜單的事件處理 style=style1; textarea.setFont(new java.awt.Font(,style,font.getSize(); if(e.getSource()=menuitem_italic) style=style2; textarea.setFont(new java.awt.Font(,style,font.getSize(); if(

29、e.getSource()=menuitem_normal) style=style3; textarea.setFont(new java.awt.Font(,style,font.getSize(); if(e.getSource()=menuitem_12) textarea.setFont(new java.awt.Font(font.getName(),style,12); if(e.getSource()=menuitem_24) textarea.setFont(new java.awt.Font(font.getName(),style,24); if(e.getSource(

30、)=menuitem_36) textarea.setFont(new java.awt.Font(font.getName(),style,36); if(e.getSource()=menuitem_seek) /查找菜單項(xiàng)的處理事件 dialog.setVisible(true); seek=textarea.getText(); String tseek=textfield_seek.getText(); if(e.getSource()=button_seek) int i=textfield_seek.getText().length(); int j=seek.indexOf(t

31、seek); textarea.setSelectionStart(j); textarea.setSelectionEnd(i+j); textfield_seek.setText(); public void itemStateChanged(ItemEvent e) /ItemListener事件處理方法 if(e.getSource()=rbmi_red) textarea.setForeground(java.awt.Color.red); if(e.getSource()=rbmi_blue) textarea.setForeground(java.awt.Color.blue);

32、 if(e.getSource()=rbmi_green) textarea.setForeground(java.awt.Color.green); public void mouseClicked(MouseEvent mec) /鼠標(biāo)處理事件 if (mec.getModifiers()=mec.BUTTON3_MASK) popupmenu.show(textarea,mec.getX(),mec.getY(); public void mousePressed(MouseEvent mep) public void mouseReleased(MouseEvent mer) publ

33、ic void mouseEntered(MouseEvent mee) public void mouseExited(MouseEvent mex) public void mouseDragged(MouseEvent med) public static void main(String arg) /main方法 new Notepad(文本編輯器); 編譯代碼實(shí)現(xiàn)各種功能:打開任意目錄下一文本文件:文件目錄下“另存為”功能:編輯目錄下“查找”功能:編輯目錄下“復(fù)制”“剪切”“粘貼”功能:字體設(shè)置功能:編輯目錄下“顏色“功能:設(shè)置字型功能:設(shè)置字號(hào)功能:運(yùn)行完畢,可關(guān)閉窗口退出程序或點(diǎn)

34、擊文件目錄下的“退出”功能5. 軟件發(fā)布首先制作Manifest文件,代碼如下;Manifest-Version:1.0Mani-Class: notepadCreated-Boy:1.6(Sun Microsystems Inc.)保存為Manifest.mf,保存在D:java打開CMD 在DOS下生成jar文件:D:javajar cmf Notepad.jar Manifest.mf notepad.class生成JAR文件,雙擊運(yùn)行。6課程小結(jié)這次JAVA課程設(shè)計(jì)給我的最大的印象就是如果自己有了興趣,就動(dòng)手去做,困難在你的勇氣和毅力下是抬不了頭的。學(xué)習(xí)面向?qū)ο笠呀?jīng)有一學(xué)期了,想想走過

35、的路程,顯得頗為有些艱辛,走了不少?gòu)澛?但總的說(shuō)來(lái),還是有不少的成績(jī)。從vc+的面向?qū)ο箝_始,我便接受了一種全新的思維方式,一改以前在面向過程中常用的方法.通過面向?qū)ο缶幊谭椒?,使得我在編程的時(shí)候,顯得更有思路和結(jié)構(gòu),尤其是它獨(dú)有的封裝性、多態(tài)性和繼承性特征,給了我莫大的幫助,這也是面向?qū)ο鬄槟壳白盍餍械乃季S方法的原因。首先,面向?qū)ο蟮木幊谭椒? 是靠“對(duì)象”來(lái)實(shí)現(xiàn)的,所謂對(duì)象也就是對(duì)事物特點(diǎn)的一種總體抽象,在程序中,我們也可以把它看成是一個(gè)基本的程序模塊。面向?qū)ο蠛腿说乃季S比較類似,這也是優(yōu)于面向過程的地方,掌握起來(lái)要比面向過程難一些。但如果這種技術(shù)能夠用得好的話,代碼就會(huì)比使用面向過程技術(shù)

36、寫出來(lái)的要簡(jiǎn)潔、易修改。同時(shí),面向?qū)ο蠓椒ǚ峙淞祟?、屬性、方法、消息機(jī)制等元素,用來(lái)進(jìn)行具體化對(duì)象的操作。對(duì)于類,我是這樣理解的,類是一個(gè)對(duì)一組相似對(duì)象的一般性描述(如,模板、模式或藍(lán)圖)。而一個(gè)程序又可以包含若干個(gè)類或是其子類,每種類也即是一種類型的封裝。在此基礎(chǔ)上 ,便引出了多態(tài)性的概念,對(duì)于某個(gè)類,如果要使用其中的變量或是函數(shù)方法,但又考慮到程序的簡(jiǎn)潔、邏輯與可讀性,我們就可以在此類的基礎(chǔ)上進(jìn)行豐富,操作方法是先繼承(根據(jù)繼承類型的不同,函數(shù)體的訪問方法也不一致,屬性的繼承、方法的繼承),這樣在以后的方法中,就可以實(shí)現(xiàn)和前一類中函數(shù)體,同樣的功能。與此同時(shí),也可以實(shí)現(xiàn)這個(gè)類的多態(tài),就可以有不同的操作功能(根據(jù)需要進(jìn)行設(shè)定)。在vc+中可以實(shí)現(xiàn)類的多繼承,也就是同一個(gè)類可以被其他多個(gè)類繼承,而每個(gè)類又可以被子類在繼承,這在程序的設(shè)計(jì)方法中,實(shí)現(xiàn)了代碼的復(fù)用,使得程序更簡(jiǎn)潔、可讀。從做這個(gè)JAVA開始無(wú)論遇到什么困難,我都沒有一絲的放棄的念頭。出于對(duì)知識(shí)的渴望,出于對(duì)新技術(shù)的好奇,出于對(duì)一切未知的求知。我完成了這次JAVA課程設(shè)計(jì),不過這只是我學(xué)習(xí)路上的驛站,各種語(yǔ)言本來(lái)就是相通的,語(yǔ)言并不重要畢竟它僅僅是工具,用好一個(gè)工具并不是一件值得為外人道的事情,主要是了解學(xué)習(xí)思想。通過自己的不懈的努力,經(jīng)過兩周的程序課程設(shè)計(jì)讓我感受很深,很是受益匪淺。

展開閱讀全文
溫馨提示:
1: 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!