版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
第第頁Java英漢電子字典課程設(shè)計源代碼Java英漢電子字典課程設(shè)計源代碼
用戶需求分析:
英漢詞典作為一個常用的學(xué)習(xí)工具,是我們常常要運用的。該系統(tǒng)能完成一個簡約的電子詞的功能。該系統(tǒng)主要用于實現(xiàn)英漢互譯的功能,系統(tǒng)擁有自己的數(shù)據(jù)庫。
1.英譯漢功能:我們可以先選擇讓系統(tǒng)進行英譯漢功能,然后在查找框中輸入想要查詢的英文單詞,系統(tǒng)將自動在數(shù)據(jù)庫中查找匹配記錄并給出相對應(yīng)的漢語意思。
2.漢譯英功能:我們可以在系統(tǒng)中選擇漢譯英功能,然后在查找框中輸入想要查詢的漢語意思,系統(tǒng)將自動在數(shù)據(jù)庫中查找匹配記錄并給出相對應(yīng)的英文單詞
3.詞匯的添加功能:用戶可以添加詞庫內(nèi)沒有的單詞及其說明。添加勝利后該單詞將在次庫內(nèi)保存,以便下次查詢。
4.詞匯的修改功能;用戶可以實現(xiàn)對詞庫中已有單詞及其說明的修改。修改后的結(jié)果將保存在詞庫中。
5.詞匯的刪除功能;用戶可自行刪除詞庫中已有的單詞,同時次單詞的說明也將被一同刪除。
6.其他功能:此外,系統(tǒng)還具有援助和關(guān)于等功能,用來幫助用戶更方便簡潔的運用電子詞典。
packagedianzicidian;
importjava.awt.*;
import.*;
importjava.sql.*;
importjava.awt.event.*;
importjava*.swing.JOptionPane;
importjava.io.*;
importsun.audio.*;
classdzcde*tendsFrameimplementsActionListener
{
MenuBarmenubar=newMenuBar();//菜單
MenufileMenu,editMenu,helpMenu;
MenuItemfileenglish,filechinese,e*it,editAdd,editmod,editDel;
Te*tFieldinputte*t;
Te*tAreat*t;
Labellabel1,label2;
Buttonbtn1,btnsound;
Panelp,p1,p2,p3;
dzcd()
{
super(電子詞典);
setBounds(200,300,350,400);
setMenuBar(menubar);
Java英漢電子字典課程設(shè)計源代碼
fileMenu=newMenu(文件);
editMenu=newMenu(編輯);
helpMenu=newMenu(援助);
fileenglish=newMenuItem(英漢詞典);
filechinese=newMenuItem(漢英詞典);
e*it=newMenuItem(退出);
editAdd=newMenuItem(添加詞匯);
editmod=newMenuItem(修改詞匯);
editDel=newMenuItem(刪除詞匯);
menubar.add(fileMenu);
menubar.add(editMenu);
menubar.add(helpMenu);
fileMenu.add(fileenglish);
fileMenu.add(filechinese);
fileMenu.addSeparator();
fileMenu.add(e*it);
editMenu.add(editAdd);
editMenu.add(editmod);
editMenu.add(editDel);
inputte*t=newTe*tField(,10);
t*t=newTe*tArea(10,10);
label1=newLabel(輸入要查詢的英語單詞:);
label2=newLabel(查詢結(jié)果:);
btn1=newButton(查詢);
btnsound=newButton(發(fā)音);
p=newPanel(newBorderLayout());
p2=newPanel(newFlowLayout(FlowLayout.LEFT,5,0));
p2.add(label1);
p2.add(inputte*t);
p2.add(btn1);
p2.add(btnsound);
add(p2,North);
p.add(label2,North);
p.add(t*t,Center);
add(p,Center);
setVisible(true);
Java英漢電子字典課程設(shè)計源代碼
setResizable(false);
validate();
fileenglish.addActionListener(this);
filechinese.addActionListener(this);
e*it.addActionListener(this);
editAdd.addActionListener(this);
editmod.addActionListener(this);
editDel.addActionListener(this);
btn1.addActionListener(this);
btnsound.addActionListener(this);
addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
System.e*it(0);
}
});
}
publicvoidactionPerformed(ActionEvente)
{
if(e.getSource()==fileenglish)//英漢〔外觀改變〕
{
label1.setTe*t(輸入要查詢的英語單詞:);
label2.setTe*t(查詢結(jié)果:);
t*t.setTe*t();
btn1.setLabel(查詢);
btnsound.setVisible(true);
}
elseif(e.getSource()==filechinese)//漢英〔外觀改變〕
{
label1.setTe*t(輸入要查詢的漢語詞語:);
label2.setTe*t(查詢結(jié)果:);
t*t.setTe*t();
btn1.setLabel(查詢);
btnsound.setVisible(true);
}
elseif(e.getSource()==e*it)//退出
{
System.e*it(0);
}
elseif(e.getSource()==btn1)
Java英漢電子字典課程設(shè)計源代碼
{
if(btn1.getLabel().equals(查詢))//實現(xiàn)查詢功能〔包括英漢或漢英〕{
t*t.setTe*t(null);
try
{
Listwords();
}
catch(SQLE*ceptionee){}
}
elseif(btn1.getLabel().equals(提交))//實現(xiàn)添加功能
{
try
{
addwords();
}
catch(SQLE*ceptionee){}
}
elseif(btn1.getLabel().equals(更新))//實現(xiàn)修改功能
{
try
{
modwords();
}
catch(SQLE*ceptionee){}
}
elseif(btn1.getLabel().equals(刪除))//實現(xiàn)刪除功能
{
try
{
delwords();
}
catch(SQLE*ceptionee){}
}
}
elseif(e.getSource()==editAdd)//添加〔外觀改變〕
{
label1.setTe*t(輸入新單詞:);
label2.setTe*t(輸入中文說明:);
btn1.setLabel(提交);
btnsound.setVisible(false);
}
elseif(e.getSource()==editmod)//修改〔外觀改變〕
{
Java英漢電子字典課程設(shè)計源代碼
label1.setTe*t(輸入要修改的單詞:);
label2.setTe*t(輸入更新后的說明:);
btn1.setLabel(更新);
btnsound.setVisible(false);
}
elseif(e.getSource()==editDel)//刪除〔外觀改變〕
{
label1.setTe*t(輸入要刪除的單詞:);
label2.setTe*t();
btn1.setLabel(刪除);
btnsound.setVisible(false);
}
elseif(e.getSource()==btnsound)//發(fā)音
{
if(inputte*t.getTe*t()!=null)
{
try
{
InputStreamis=getClass().getResource(sound//+
inputte*t.getTe*t().trim()+.wav).openStream();
AudioPlayer.player.start(is);
}
catch(IOE*ceptione1){}
}
}
}
publicvoidListwords()throwsSQLE*ception//查詢實現(xiàn)過程
{
Stringcname,ename;
try
{
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
}
catch(ClassNotFoundE*ceptione){}
ConnectionE*1Con=DriverManager.getConnection(jdbc:odbc:words,,);StatementE*1Stmt=E*1Con.createStatement();
ResultSetrs=E*1Stmt.e*ecuteQuery(SELECT*FROMwords);
booleanboo=false;
while((boo=rs.ne*t())==true)
{
Java英漢電子字典課程設(shè)計源代碼
ename=rs.getString(英語);
cname=rs.getString(漢語);
if(ename.equals(inputte*t.getTe*t())
label1.getTe*t().equals(輸入要查詢的英語單詞:))
{
t*t.append(cname);
break;
}
elseif(cname.equals(inputte*t.getTe*t())
label1.getTe*t().equals(輸入要查詢的漢語詞語:))
{
t*t.append(ename);
break;
}
}
E*1Con.close();
if(boo==false)
{
JOptionPane.showMessageDialog(this,查無此單詞!,警告,
JOptionPane.WARNING_MESSAGE);
}
}
publicvoidaddwords()throwsSQLE*ception//向數(shù)據(jù)庫添加新詞匯
{
Stringcname,ename;
try
{
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
}
catch(ClassNotFoundE*ceptione){}
ConnectionE*1Con=DriverManager.getConnection(jdbc:odbc:words,,);StatementE*1Stmt=E*1Con.createStatement();
ResultSetrs=E*1Stmt.e*ecuteQuery(SELECT*FROMwords);
booleanboo=false;
while((boo=rs.ne*t())==true)
{
ename=rs.getString(英語);
cname=rs.getString(漢語);
if(ename.equals(inputte*t.getTe*t())cname.equals(t*t.getTe*t())){
JOptionPane.showMessageDialog(this,此詞匯已存在!,警告,JOptionPane.WARNING_MESSAGE);
Java英漢電子字典課程設(shè)計源代碼
break;}}if(boo==false){E*1Stmt.e*ecuteUpdate(INSERTINTOwords(英語,漢語)VALUES('+inputte*t.getTe*t().trim()+','+t*t.getTe*t().trim()+'));JOptionPane.showMessageDialog(this,添加勝利!,恭喜,JOptionPane.WARNING_MESSAGE);}E*1Con.close();}publicvoidmodwords()throwsSQLE*ception//修改詞庫中記錄{Stringename;try{Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);}catch(ClassNotFoundE*ceptione){}ConnectionE*1Con=DriverManager.getConnection(jdbc:odbc:words,,);StatementE*1Stmt=E*1Con.createStatement();ResultSetrs=E*1Stmt.e*ecuteQuery(SELECT*FROMwords);booleanboo=false;while((boo=rs.ne*t())==true){ename=rs.getString(英語);if(ename.equals(inputte*t.getTe*t())){E*1Stmt.e*ecuteUpdate(UPDATEwordsSET漢語='+t*t.getTe*t().trim()+'WHERE英語='+inputte*t.getTe*t().trim()+');JOptionPane.showMessageDialog(this,記錄修改勝利!,恭喜,JOptionPane.WARNING_MESSAGE);break;}}E*1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,不存在此單詞!,警告,JOptionPane.WARNING_MESSAGE);}
Java英漢電子字典課程設(shè)計源代碼
}
publicvoiddelwords()throwsSQLE*ception//刪除詞庫中記錄
{
@SuppressWarnings(unused)
Stringcname,ename;
try
{
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
}
catch(ClassNotFoundE*ceptione){}
Connection
E*1Con=DriverManager.getConnection(jdbc:odbc:wordskechengsheji,,);StatementE*1Stmt=E*1Con.createStatement();
ResultSetrs=E*1Stmt.e*ecuteQuery(SELECT*FROMwords);
booleanboo=false;
while((boo=rs.ne*t())==true)
{
ename=rs.getString(英語);
cname=rs.getString(漢語);
if(ename.equals(inputte*t.getTe*t()))
{
E*1Stmt.e*ecuteUpdate(DELETEFROMwordsWHERE英語='+inputte*t.getTe*t().trim()+');
JOptionPane.showMessageDialog(this,勝利刪除記錄!,恭喜,JOptionPane.WARNING_MESSAGE);
break;
}
}
E*1Con.close();
if(boo==false)
{
JOptionPane.showMessageDialog(this,不存在此單詞!,警告,JOptionPane.WARNING_MESSAGE);
}
}
publicstaticvoidmain(Stringargs[])
{
newdzcd();
}
}
Java英漢電子字典課程設(shè)計源代碼
用戶需求分析:
英漢詞典作為一個常用的學(xué)習(xí)工具,是我們常常要運用的。該系統(tǒng)能完成一個簡約的電子詞的功能。該系統(tǒng)主要用于實現(xiàn)英漢互譯的功能,系統(tǒng)擁有自己的數(shù)據(jù)庫。
1.英譯漢功能:我們可以先選擇讓系統(tǒng)進行英譯漢功能,然后在查找框中輸入想要查詢的
溫馨提示
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 電氣接地檢測技術(shù)要領(lǐng)
- 數(shù)控編程考試題庫及答案
- 審評規(guī)則考試題及答案
- 審計實務(wù)試卷試題及答案
- 融資專崗招聘考試題庫及答案
- 《GAT 974.90-2015消防信息代碼 第90部分:滅火器類型代碼》專題研究報告
- 2026年深圳中考英語任務(wù)型閱讀專項試卷(附答案可下載)
- 2026年深圳中考英語創(chuàng)新題型特訓(xùn)試卷(附答案可下載)
- 2026年深圳中考數(shù)學(xué)圓的相關(guān)性質(zhì)試卷(附答案可下載)
- 2026年深圳中考生物人體的神經(jīng)調(diào)節(jié)專項試卷(附答案可下載)
- 設(shè)計成果保密管理制度
- 珠寶文化課件
- GB/T 43590.506-2025激光顯示器件第5-6部分:投影屏幕光學(xué)性能測試方法
- 電工職業(yè)衛(wèi)生試題及答案
- 五年級第一學(xué)期勞動課教學(xué)計劃和總結(jié)
- 《骨及關(guān)節(jié)疾病》課件
- QES三體系建筑施工企業(yè)管理手冊(含50430)
- 物業(yè)管理技巧與經(jīng)驗分享
- GB/T 44179-2024交流電壓高于1 000 V和直流電壓高于1 500 V的變電站用空心支柱復(fù)合絕緣子定義、試驗方法和接收準則
- 德漢翻譯入門智慧樹知到期末考試答案章節(jié)答案2024年中國海洋大學(xué)
- MT-T 1199-2023 煤礦用防爆柴油機無軌膠輪運輸車輛安全技術(shù)條件
評論
0/150
提交評論