Word版可編輯-Java英漢電子字典課程設計源代碼精心整理.doc_第1頁
Word版可編輯-Java英漢電子字典課程設計源代碼精心整理.doc_第2頁
Word版可編輯-Java英漢電子字典課程設計源代碼精心整理.doc_第3頁
Word版可編輯-Java英漢電子字典課程設計源代碼精心整理.doc_第4頁
Word版可編輯-Java英漢電子字典課程設計源代碼精心整理.doc_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

用戶需求分析:英漢詞典作為一個常用的學習工具,是我們經常要使用的。該系統(tǒng)能完成一個簡單的電子詞的功能。該系統(tǒng)主要用于實現(xiàn)英漢互譯的功能,系統(tǒng)擁有自己的數據庫。1.英譯漢功能:我們可以先選擇讓系統(tǒng)進行英譯漢功能,然后在查找框中輸入想要查詢的英文單詞,系統(tǒng)將自動在數據庫中查找匹配記錄并給出相對應的漢語意思。2.漢譯英功能:我們可以在系統(tǒng)中選擇漢譯英功能,然后在查找框中輸入想要查詢的漢語意思,系統(tǒng)將自動在數據庫中查找匹配記錄并給出相對應的英文單詞3.詞匯的添加功能:用戶可以添加詞庫內沒有的單詞及其解釋。添加成功后該單詞將在次庫內保存,以便下次查詢。4.詞匯的修改功能;用戶可以實現(xiàn)對詞庫中已有單詞及其解釋的修改。修改后的結果將保存在詞庫中。5.詞匯的刪除功能;用戶可自行刪除詞庫中已有的單詞,同時次單詞的解釋也將被一同刪除。6.其他功能:此外,系統(tǒng)還具有幫助和關于等功能,用來輔助用戶更方便簡潔的使用電子詞典。package dianzicidian;import java.awt.*;import .*;import java.sql.*;import java.awt.event.*;import javax.swing.JOptionPane;import java.io.*;import sun.audio.*;class dzcd extends Frame implements ActionListenerMenuBar menubar=new MenuBar();/菜單Menu fileMenu,editMenu,helpMenu;MenuItem fileenglish,filechinese,exit,editAdd,editmod,editDel;TextField inputtext;TextArea txt;Label label1,label2;Button btn1,btnsound;Panel p,p1,p2,p3;dzcd()super(電子詞典);setBounds(200,300,350,400);setMenuBar(menubar);fileMenu=new Menu(文件);editMenu=new Menu(編輯);helpMenu=new Menu(幫助);fileenglish=new MenuItem(英漢詞典);filechinese=new MenuItem(漢英詞典);exit=new MenuItem(退出);editAdd=new MenuItem(添加詞匯);editmod=new MenuItem(修改詞匯);editDel=new MenuItem(刪除詞匯);menubar.add(fileMenu);menubar.add(editMenu);menubar.add(helpMenu);fileMenu.add(fileenglish);fileMenu.add(filechinese);fileMenu.addSeparator();fileMenu.add(exit);editMenu.add(editAdd);editMenu.add(editmod);editMenu.add(editDel);inputtext=new TextField(,10);txt=new TextArea(10,10);label1=new Label(輸入要查詢的英語單詞:);label2=new Label(查詢結果:);btn1=new Button(查詢);btnsound=new Button(發(fā)音);p=new Panel(new BorderLayout();p2=new Panel(new FlowLayout(FlowLayout.LEFT,5,0);p2.add(label1);p2.add(inputtext);p2.add(btn1);p2.add(btnsound);add(p2,North);p.add(label2,North);p.add(txt,Center);add(p,Center);setVisible(true);setResizable(false);validate();fileenglish.addActionListener(this);filechinese.addActionListener(this);exit.addActionListener(this);editAdd.addActionListener(this);editmod.addActionListener(this);editDel.addActionListener(this);btn1.addActionListener(this);btnsound.addActionListener(this);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););public void actionPerformed(ActionEvent e)if(e.getSource()=fileenglish)/英漢(外觀變化)label1.setText(輸入要查詢的英語單詞:);label2.setText(查詢結果:);txt.setText();btn1.setLabel(查詢);btnsound.setVisible(true);else if(e.getSource()=filechinese)/漢英(外觀變化)label1.setText(輸入要查詢的漢語詞語:);label2.setText(查詢結果:);txt.setText();btn1.setLabel(查詢);btnsound.setVisible(true);else if(e.getSource()=exit)/退出System.exit(0);else if(e.getSource()=btn1)if(btn1.getLabel().equals(查詢)/實現(xiàn)查詢功能(包括英漢或漢英)txt.setText(null);tryListwords();catch(SQLException ee)else if(btn1.getLabel().equals(提交)/實現(xiàn)添加功能tryaddwords();catch(SQLException ee)else if(btn1.getLabel().equals(更新)/實現(xiàn)修改功能trymodwords();catch(SQLException ee)else if(btn1.getLabel().equals(刪除)/實現(xiàn)刪除功能trydelwords();catch(SQLException ee)else if(e.getSource()=editAdd)/添加(外觀變化)label1.setText(輸入新單詞:);label2.setText(輸入中文解釋:);btn1.setLabel(提交);btnsound.setVisible(false);else if(e.getSource()=editmod)/修改(外觀變化)label1.setText(輸入要修改的單詞:);label2.setText(輸入更新后的解釋:);btn1.setLabel(更新);btnsound.setVisible(false);else if(e.getSource()=editDel)/刪除(外觀變化)label1.setText(輸入要刪除的單詞:);label2.setText();btn1.setLabel(刪除);btnsound.setVisible(false);else if(e.getSource()=btnsound)/發(fā)音if(inputtext.getText()!=null)try InputStream is=getClass().getResource(sound/+ inputtext.getText().trim()+.wav).openStream(); AudioPlayer.player.start(is); catch(IOException e1)public void Listwords() throws SQLException/查詢實現(xiàn)過程String cname,ename;tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch(ClassNotFoundException e)Connection Ex1Con=DriverManager.getConnection(jdbc:odbc:words,);Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery(SELECT * FROM words);boolean boo=false;while(boo=rs.next()=true)ename=rs.getString(英語);cname=rs.getString(漢語);if(ename.equals(inputtext.getText()&label1.getText().equals(輸入要查詢的英語單詞:)txt.append(cname);break;else if(cname.equals(inputtext.getText()&label1.getText().equals(輸入要查詢的漢語詞語:)txt.append(ename);break;Ex1Con.close();if(boo=false)JOptionPane.showMessageDialog(this,查無此單詞!,警告,JOptionPane.WARNING_MESSAGE);public void addwords() throws SQLException/向數據庫添加新詞匯String cname,ename;tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch(ClassNotFoundException e)Connection Ex1Con=DriverManager.getConnection(jdbc:odbc:words,);Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery(SELECT * FROM words);boolean boo=false;while(boo=rs.next()=true)ename=rs.getString(英語);cname=rs.getString(漢語);if(ename.equals(inputtext.getText()&cname.equals(txt.getText()JOptionPane.showMessageDialog(this,此詞匯已存在!,警告,JOptionPane.WARNING_MESSAGE);break;if(boo=false)Ex1Stmt.executeUpdate(INSERT INTO words (英語,漢語) VALUES (+inputtext.getText().trim()+,+txt.getText().trim()+);JOptionPane.showMessageDialog(this,添加成功!,恭喜,JOptionPane.WARNING_MESSAGE);Ex1Con.close();public void modwords() throws SQLException/修改詞庫中記錄String ename;tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch(ClassNotFoundException e)Connection Ex1Con=DriverManager.getConnection(jdbc:odbc:words,);Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery(SELECT * FROM words);boolean boo=false;while(boo=rs.next()=true)ename=rs.getString(英語);if(ename.equals(inputtext.getText()Ex1Stmt.executeUpdate(UPDATE words SET 漢語=+txt.getText().trim()+ WHERE 英語=+inputtext.getText().trim()+);JOptionPane.showMessageDialog(this,記錄修改成功!,恭喜,JOptionPane.WARNING_MESSAGE);break;Ex1Con.close();if(boo=false)JOptionPane.showMessageDialog(this,不存在此單詞!,警告,JOptionPane.WARNING_MESSAGE);public void delwords() throws SQLException/刪除詞庫中記錄SuppressWarnings(unused)String cname,ename;tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);c

溫馨提示

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

評論

0/150

提交評論