記事本程序源代碼匯總_第1頁
記事本程序源代碼匯總_第2頁
記事本程序源代碼匯總_第3頁
記事本程序源代碼匯總_第4頁
記事本程序源代碼匯總_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

import java awt event import java awt import java io import java lang String class jsb implements ActionListener Dialog bb String strt int i FileDialog fd File file public Frame f public TextArea p1 public MenuBar menubar public Menu menu1 menu2 menu3 public MenuItem item1 item2 item3 item4 item5 item6 item7 item8 item9 item10 jsb String s i 0 f new Frame s p1 new TextArea f setSize 500 500 f setBackground Color white f setVisible true menubar new MenuBar menu1 new Menu 文件 menu2 new Menu 編輯 menu3 new Menu 幫助 item1 new MenuItem 新建 item2 new MenuItem 打開 item3 new MenuItem 保存 item4 new MenuItem 另存為 item5 new MenuItem 退出 item6 new MenuItem 全選 item7 new MenuItem 復(fù)制 item8 new MenuItem 剪切 item9 new MenuItem 粘貼 item10 new MenuItem 關(guān)于 f addWindowListener new WindowAdapter public void windowClosing WindowEvent e f setVisible false System exit 0 menu1 add item1 menu1 add item2 menu1 add item3 menu1 add item4 menu1 add item5 menu2 add item6 menu2 add item7 menu2 add item8 menu2 add item9 menu3 add item10 menubar add menu1 menubar add menu2 menubar add menu3 f setMenuBar menubar item1 addActionListener this item2 addActionListener this item3 addActionListener this item4 addActionListener this item5 addActionListener this item6 addActionListener this item7 addActionListener this item8 addActionListener this item9 addActionListener this item10 addActionListener this f setLayout new GridLayout 1 1 f add p1 f pack public void actionPerformed ActionEvent e String ss ss p1 getText trim if e getSource item5 if i 0 else System exit 0 if e getSource item1 if i 0 else p1 setText i 0 f setTitle 文件對話框 if e getSource item2 fd new FileDialog f 打開文件 0 fd setVisible true try file new File fd getDirectory fd getFile f setTitle fd getFile 文件對話框 FileReader fr new FileReader file BufferedReader br new BufferedReader fr String line null String view while line br readLine null view line n p1 setText view br close fr close catch IOException expIn if e getSource item3 if i 0 bc else try file new File fd getDirectory fd getFile f setTitle fd getFile 記事本 FileWriter fw new FileWriter file BufferedWriter bw new BufferedWriter fw String s p1 getText s s replaceAll n r n bw write s bw flush bw close fw close i 1 catch IOException expOut i 0 if e getSource item4 bc if e getSource item10 bb new Dialog f 關(guān)于 Label l1 new Label 本記事本的完成感謝老師和同學(xué)的幫助 bb add l1 bb setSize 250 150 bb setBackground Color white bb show bb addWindowListener new WindowAdapter public void windowClosing WindowEvent e bb setVisible false bb dispose if e getSource item6 p1 setSelectionStart 0 p1 setSelectionEnd p1 getText length if e getSource item7 try String str p1 getSelectedText if str length 0 strt str catch Exception ex if e getSource item8 try String str p1 getSelectedText if str length 0 p1 replaceRange p1 getSelectionStart p1 getSelectionEnd catch Exception ex if e getSource item9 if strt length 0 p1 insert strt p1 getCaretPosition public void bc fd new FileDialog f 保存文件 1 fd setVisible true try file new File fd getDirectory fd getFile f setTitle fd getFile 記事本 FileWriter fw new FileWriter file BufferedWriter bw new BufferedWriter fw String s p1 getText

溫馨提示

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

評論

0/150

提交評論