歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOC文檔下載  

Java課程設(shè)計 記事本 課程設(shè)計

  • 資源ID:32751687       資源大小:161.51KB        全文頁數(shù):21頁
  • 資源格式: DOC        下載積分:15積分
快捷下載 游客一鍵下載
會員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要15積分
郵箱/手機:
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機號,方便查詢和重復(fù)下載(系統(tǒng)自動生成)
支付方式: 支付寶    微信支付   
驗證碼:   換一換

 
賬號:
密碼:
驗證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會被瀏覽器默認打開,此種情況可以點擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標題沒有明確說明有答案則都視為沒有答案,請知曉。

Java課程設(shè)計 記事本 課程設(shè)計

課程設(shè)計說明課程名稱: Java課程設(shè)計 設(shè)計題目: 記事本 專 業(yè): 班級: 學(xué)生姓名: 學(xué) 號: 指導(dǎo)教師: 科技學(xué)院教務(wù)部 制年 月 日一、系統(tǒng)設(shè)計目的:1)設(shè)計一個簡單的Windows記事本,可以實現(xiàn)以下功能: 1:文件的新建,打開,保存; 2:對文件的編輯,如全選,復(fù)制,剪切,粘貼;3、工具,進行大小寫的轉(zhuǎn)換 4:執(zhí)行完操作后,能夠順利關(guān)閉記事本; 2)通過這次設(shè)計,可以幫助學(xué)生:1:提高對Java語言設(shè)計的掌握能力; 2:理論聯(lián)系實際,進一步提高學(xué)生的軟件開發(fā)技術(shù); 3:培養(yǎng)學(xué)生分析、解決問題的能力。二、系統(tǒng)實現(xiàn)思路:設(shè)計兩個類,一個mynotepad類,具有程序的要求和功能再創(chuàng)建一個Notepad主類,在主類中創(chuàng)建一個mynotepad類的對象,就可以直接在編譯器中運行程序。1:界面設(shè)計在主界面中設(shè)計一個iFrame容器,并在其中加入一個下拉菜單和一個文本域控件。 2:功能設(shè)計在下拉菜單中加入子菜單并進行監(jiān)聽,分別實現(xiàn)對文件的操作功能。點擊不同菜單項時,進行不同的操作。 3:代碼設(shè)計編寫每個控件的相關(guān)代碼,并進行調(diào)試。三、系統(tǒng)詳細設(shè)計1:界面設(shè)計創(chuàng)建一個下拉菜單和文本域,在文本域中顯示編輯的文件信息。主要代碼:JMenu menus=new JMenunew JMenu("文件"),new JMenu("編輯"),new JMenu("工具"),new JMenu("關(guān)于");JMenuItem optionofmenu=new JMenuItemnew JMenuItem("新建"),new JMenuItem("打開"),new JMenuItem("保存"),new JMenuItem("退出") , new JMenuItem("復(fù)制"), new JMenuItem("剪切"),new JMenuItem("粘貼"),new JMenuItem("文字顏色"),new JMenuItem("背景顏色") , new JMenuItem("大寫轉(zhuǎn)小寫"), new JMenuItem("小寫轉(zhuǎn)大寫"), , new JMenuItem("關(guān)于") ; void initMenu() for(int i=0;i<menus.length;i+) menu.add(menusi); for(int j=0;j<optionofmenui.length;j+) menusi.add(optionofmenuij); optionofmenuij.addActionListener( action ); this.setJMenuBar(menu); 2:功能設(shè)計部分菜單項的相關(guān)代碼:新建文件 ActionListener action=new ActionListener() /事件 public void actionPerformed(ActionEvent e) String name = e.getActionCommand();JMenuItem MI=(JMenuItem)e.getSource();if("新建".equals(name)content.setText("");file=null;else if("打開".equals(name) if(file !=null)openfile.setSelectedFile(file); int returnVal=openfile.showOpenDialog(mynotepad.this); if(returnVal=JFileChooser.APPROVE_OPTION) file=openfile.getSelectedFile(); unfold(); else if("保存".equals(name) if(file!=null) openfile.setSelectedFile(file); int returnVal=openfile.showSaveDialog(mynotepad.this); if(returnVal=JFileChooser.APPROVE_OPTION) file=openfile.getSelectedFile(); saving(); else if("退出".equals(name) mynotepad f=new mynotepad(); int s=JOptionPane.showConfirmDialog(f,"退出?","退出",JOptionPane.YES_NO_OPTION); if(s=JOptionPane.YES_OPTION) System.exit(0); else if("剪切".equals(name) content.cut(); else if("復(fù)制".equals(name) content.copy(); else if("粘貼".equals(name) content.paste(); else if("文字顏色".equals(name) color=JColorChooser.showDialog(mynotepad.this,"",color); content.setForeground(color); else if("背景顏色".equals(name) color=JColorChooser.showDialog(mynotepad.this,"",color); content.setBackground(color); else if("大寫轉(zhuǎn)小寫".equals(name) String str=content.getText(); String str1=str.toLowerCase(); content.setText(str1); else if("小寫轉(zhuǎn)大寫".equals(name) String str=content.getText(); String str1=str.toUpperCase(); content.setText(str1); else if("關(guān)于".equals(name) JOptionPane.showMessageDialog(null,"程序制作:鄭澤波&魯裕浩&歐陽國勝&曾成成","關(guān)于",JOptionPane.INFORMATION_MESSAGE); 四、系統(tǒng)調(diào)試運行1:界面調(diào)試確定主窗體,設(shè)置主窗體的屬性,對窗體進行布局,加入所需控件并對控件進行初始化。在完成加入菜單控件后,不能缺少this.setJMenuBar(menu); 語句,將menu設(shè)為主窗體的菜單條,否則會看不到菜單欄。如圖:2:功能調(diào)試打開功能:保存功能:五、課程設(shè)計心得經(jīng)過一個星期的我的記事本的課程設(shè)計,我在向華萍老師的指導(dǎo)下,順利完成該課程設(shè)計。通過該課程設(shè)計,收獲頗多。首先,讓我加深了對Java語言的理論知識的理解;其次,讓我更加熟練的掌握了Java語言的設(shè)計能力并且有了實踐經(jīng)驗;再次,在設(shè)計過程中,學(xué)到了老師沒有在課堂上沒有教授的知識;最后,加強了我對Java語言的學(xué)習(xí)興趣和好感。六、參考文獻:1 耿詳義,張躍平. Java 2 實用教程. 北京:清華大學(xué)出版社,2004.22 張利國.Java實用教程案例.北京:清華大學(xué)出版社,2003.103 周曉聰,等.面向?qū)ο蟪绦蛟O(shè)計與Java語言.北京:機械工業(yè)出版社,2004.34 李尊朝.Java語言程序設(shè)計.北京:中國鐵道出版社,2004.25 (美)Philip Heller.Complate Java 2 Certification Study Guide Fourth Edition(Java 2 證學(xué)習(xí)指南) (第四版 英文版). 北京:電子工業(yè)出版社,2004.1七、附 錄程序源代碼: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 &&(ss.length()!=0) bc(); else System.exit(0); if (e.getSource()=item1) if (i=0&&(ss.length()!=0) bc(); 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","rn"); 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(); s = s.replaceAll("n","rn"); bw.write(s); bw.flush(); bw.close();fw.close(); i=1; catch(IOException expOut) public class keshe public static void main(String args) jsb dd=new jsb("我的記事本"); 第 19 頁

注意事項

本文(Java課程設(shè)計 記事本 課程設(shè)計)為本站會員(仙***)主動上傳,裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng)(點擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因為網(wǎng)速或其他原因下載失敗請重新下載,重復(fù)下載不扣分。




關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

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

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


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