




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、用戶需求分析:英漢詞典作為一個常用的學習工具,是我們經常要使用的。該系統能完成一個簡單的電子詞的功能。該系統主要用于實現英漢互譯的功能,系統擁有自己的數據庫。1.英譯漢功能:我們可以先選擇讓系統進行英譯漢功能,然后在查找框中輸入想要查詢的英文單詞,系統將自動在數據庫中查找匹配記錄并給出相對應的漢語意思。2.漢譯英功能:我們可以在系統中選擇漢譯英功能,然后在查找框中輸入想要查詢的漢語意思,系統將自動在數據庫中查找匹配記錄并給出相對應的英文單詞3.詞匯的添加功能:用戶可以添加詞庫內沒有的單詞及其解釋。添加成功后該單詞將在次庫內保存,以便下次查詢。4.詞匯的修改功能;用戶可以實現對詞庫中已有單詞及其
2、解釋的修改。修改后的結果將保存在詞庫中。5.詞匯的刪除功能;用戶可自行刪除詞庫中已有的單詞,同時次單詞的解釋也將被一同刪除。6.其他功能:此外,系統還具有幫助和關于等功能,用來輔助用戶更方便簡潔的使用電子詞典。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 impl
3、ements 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(menub
4、ar);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)
5、;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=ne
6、w 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(
7、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(WindowEv
8、ent 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(查詢結
9、果:);txt.setText();btn1.setLabel(查詢);btnsound.setVisible(true);else if(e.getSource()=exit)/退出System.exit(0);else if(e.getSource()=btn1)if(btn1.getLabel().equals(查詢)/實現查詢功能(包括英漢或漢英)txt.setText(null);tryListwords();catch(SQLException ee)else if(btn1.getLabel().equals(提交)/實現添加功能tryaddwords();catch(SQLEx
10、ception ee)else if(btn1.getLabel().equals(更新)/實現修改功能trymodwords();catch(SQLException ee)else if(btn1.getLabel().equals(刪除)/實現刪除功能trydelwords();catch(SQLException ee)else if(e.getSource()=editAdd)/添加(外觀變化)label1.setText(輸入新單詞:);label2.setText(輸入中文解釋:);btn1.setLabel(提交);btnsound.setVisible(false);else
11、 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(inpu
12、ttext.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/查詢實現過程String cname,ename;tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch(ClassNot
13、FoundException 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.getTex
14、t()&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 SQL
15、Exception/向數據庫添加新詞匯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;whil
16、e(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().
17、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.getConn
18、ection(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 英語=+i
19、nputtext.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);
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 擺攤市集活動方案
- 手機五一促銷活動方案
- 教師節(jié)搞秒殺活動方案
- 揚琴教學活動方案
- 手語比賽活動方案
- 技術落戶活動方案
- 施氮和收割頻率強化李氏禾修復土壤鉻污染效率的研究
- 抗疫活動工會活動方案
- 操場夜景活動方案
- 技能小組評比活動方案
- (三級)人工智能訓練師職業(yè)技能鑒定理論考試題(附答案)
- 2025杭州市臨安區(qū)事業(yè)單位招聘80人考前自測高頻考點模擬試題附答案詳解(鞏固)
- 2025年北京二十中中考英語零模試卷
- 護理服務質量提升路徑與實踐
- 糞肥還田協議書范本
- 商務數據分析-形考作業(yè)4(第5章)-國開(ZJ)-參考資料
- 有機合成與推斷綜合大題(解析版)
- 智能客服語音識別技術在醫(yī)療行業(yè)的應用現狀與發(fā)展報告
- 工勤技師考試試題及答案
- 2025-2030中國膜電極組件(MEA)行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 2025年骨干教師考試題庫全
評論
0/150
提交評論