java課程設(shè)計(jì)文檔_第1頁(yè)
java課程設(shè)計(jì)文檔_第2頁(yè)
java課程設(shè)計(jì)文檔_第3頁(yè)
java課程設(shè)計(jì)文檔_第4頁(yè)
java課程設(shè)計(jì)文檔_第5頁(yè)
已閱讀5頁(yè),還剩16頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

PAGEPAGE3JIANGXIAGRICULTURALUNIVERSITYJAVA課程設(shè)計(jì)報(bào)告題目:《寫字留痕》課程設(shè)計(jì)學(xué)院:******姓名:***學(xué)號(hào):********專業(yè):軟件工程班級(jí):軟件1****班指導(dǎo)教師:**職稱:****二0一二年月摘要學(xué)習(xí)一門語(yǔ)言,重要的是表達(dá)。課程設(shè)計(jì)就是這樣一次表達(dá)的機(jī)會(huì)?!氨磉_(dá)”,即程序設(shè)計(jì)。Java是一種可以撰寫跨平臺(tái)應(yīng)用軟件的面向?qū)ο蟮某绦蛟O(shè)計(jì)語(yǔ)言。在全球云計(jì)算和移動(dòng)互聯(lián)網(wǎng)的產(chǎn)業(yè)環(huán)境下,Java更具備了顯著優(yōu)勢(shì)和廣闊前景。隨著家庭電腦的普及,擁有一個(gè)體積小巧、使用方便、功能強(qiáng)大的記事本來(lái)記錄每一天的點(diǎn)點(diǎn)滴滴,已經(jīng)變得越來(lái)越重要。Windows自帶的記事本使用很方便,但是功能不夠強(qiáng)大,所以要開(kāi)發(fā)一款更加強(qiáng)大的軟件來(lái)滿足市場(chǎng)需求。關(guān)鍵詞:記事本。

目錄

設(shè)計(jì)需求基本設(shè)計(jì)要求:日記本使用Java語(yǔ)言開(kāi)發(fā)設(shè)計(jì)。課程的基本功能包括萬(wàn)年歷、記事本和輔助功能三個(gè)部分。萬(wàn)年歷部分由微調(diào)器確定年月,由一組文本框顯示日歷。年月可選擇數(shù)據(jù)符合邏輯,默認(rèn)為當(dāng)前日期。月歷顯示應(yīng)該符合查看習(xí)慣,如星期六和星期日分別用不同顏色表示,當(dāng)日可用特別的字號(hào)和顏色及時(shí)本區(qū),記事本內(nèi)容按年月日記錄且保存。微調(diào)器應(yīng)該進(jìn)行事件設(shè)置,以及即時(shí)地顯示該年月的月歷;日期文本框可監(jiān)聽(tīng)鼠標(biāo)事件,當(dāng)單擊任何一個(gè)日期時(shí),若該日有記事內(nèi)容,則在日記本中顯示該日期的記錄文字;若該日無(wú)記錄,記事區(qū)保持空白。日記本應(yīng)該是開(kāi)放的,內(nèi)容可按日期增減,保存應(yīng)即時(shí),刪除需謹(jǐn)慎刪除記錄時(shí),應(yīng)進(jìn)行對(duì)話框詢問(wèn)確定。輔助功能包含了日記的導(dǎo)入導(dǎo)出?!皩?dǎo)入”可以將其他日記文件導(dǎo)入合并到當(dāng)前“寫字留痕”的日記本中;“導(dǎo)出”可將“寫字留痕”的所有記錄內(nèi)容按日期為序?qū)С龅揭粋€(gè)文本文件中。系統(tǒng)界面外觀和布局,可個(gè)性化設(shè)計(jì),總體原則是“界面簡(jiǎn)潔,操作便捷”。

2系統(tǒng)設(shè)計(jì) 本系統(tǒng)采用java語(yǔ)言開(kāi)發(fā),開(kāi)發(fā)工具為記事本,運(yùn)行環(huán)境為JDK1.6。2.2總體設(shè)計(jì)結(jié)構(gòu)圖 主框架萬(wàn)年歷記事本選擇微調(diào)按鈕 輸入保存刪除導(dǎo)入導(dǎo)出 2.3萬(wàn)年歷模塊流程圖 萬(wàn)年歷 選擇微調(diào)按鈕 選擇日期 正確輸入 錯(cuò)誤輸入 改變當(dāng)天日期 當(dāng)天是否有日記? 有 無(wú) 更改記事本顯示 2.4日記本模塊流程圖 顯示日記本 保存 刪除 導(dǎo)入 導(dǎo)出以當(dāng)前日期為值,如果當(dāng)前TreeMap 打開(kāi)打開(kāi)文件對(duì)打開(kāi)保存文件當(dāng)前內(nèi)容為值保有今天的記錄就 話框,如果選擇對(duì)話框,保存存到TreeMap中刪除它 了文件就導(dǎo)入 到所選路徑下2.5主視窗界面主界面:保存界面刪除界面:導(dǎo)入文件:導(dǎo)出文件:源代碼:importjavax.swing.*;importjava.awt.*;importjava.io.*;importjava.awt.event.*;importjava.util.*;importjavax.swing.event.*;importjava.text.*;importjava.lang.*;importjavax.swing.border.*;classSexBoxextendsJPanel//設(shè)置選取天氣的面板{JComboBoxc; JComboBoxcb; SexBox() { super(newFlowLayout()); c=newJComboBox(newString[]{"晴","雨","陰","雪"}); cb=newJComboBox(newString[]{"愉快","悲傷","憂郁","平常"}); add(newJLabel("天氣")); add(c); add(newJLabel("心情")); add(cb); }}classAreaDateextendsJPanel//設(shè)置萬(wàn)年歷放置的文本{intdays; intfirst; JTextAreashowDay[]; DateTimedateTime=newDateTime(1); AreaDate() { super(newGridLayout(6,7,5,5)); showDay=newJTextArea[42]; for(inti=0;i<42;i++) { showDay[i]=newJTextArea(1,1); add(showDay[i]); } arrangeNum(dateTime.year,dateTime.month,dateTime.date); System.out.println(dateTime.year); } AreaDate(inti){} publicvoidarrangeNum(intyear,intmonth,intday) { days=dateTime.getMonday(year,month); Calendarc=Calendar.getInstance(); c.set(year,month-1,1); first=c.get(Calendar.DAY_OF_WEEK)-1; for(inti=first,n=1;i<first+days;i++,n++) { showDay[i].setText(""+n); showDay[i].setBackground(newColor(238,238,238)); if(n==c.get(c.DATE)) { showDay[i].setForeground(Color.green); showDay[i].setFont(newFont("TimesRoman",Font.BOLD,20)); } elseif(n==day) { showDay[i].setFont(newFont("TimesRoman",Font.BOLD,20)); showDay[i].setForeground(Color.white); showDay[i].setBackground(Color.GRAY); } elseif(i%7==0||i%7==6) { showDay[i].setForeground(Color.red); showDay[i].setFont(newFont("TimesRoman",Font.BOLD,20)); } else { showDay[i].setFont(newFont("TimesRoman",Font.BOLD,20)); showDay[i].setForeground(Color.black); } } for(inti=0;i<42;i++) { if(i<first||i>=first+days) { showDay[i].setBackground(newColor(238,238,238)); showDay[i].setText(""); } } }}classWeekextendsJPanel//設(shè)置星期{ JLabellab[]; //JLabellabPic; Stringstr[]={"日","一","二","三","四","五","六"}; Week() { super(newGridLayout(1,7,5,5)); init(); } publicvoidinit() { lab=newJLabel[7]; //labPic=newJLabel(newImageIcon("logo[1].png")); //add(labPic); for(inti=0;i<7;i++) { lab[i]=newJLabel(str[i]); //lab[i].setFont(newFont("楷體",Font.BOLD,20)); add(lab[i]); } }}classYearMonthextendsJPanel//設(shè)置選取時(shí)間的面板{intyear; intmonth; intdate; JLabely1,m1,d1; JSpinnershowYear,showMonth,showDate; SpinnerNumberModelyearModel,monthModel,dateModel; DateTimedateTime=newDateTime(1); YearMonth() { ymInit(); add(showYear); add(y1); add(showMonth); add(m1); add(showDate); add(d1); } voidymInit()//選取時(shí)間進(jìn)度條 { y1=newJLabel("年"); m1=newJLabel("月"); d1=newJLabel("日"); //DateTime=Calendar.getInstance(); year=dateTime.getYear(); month=dateTime.getMonth(); date=dateTime.getDate(); //areaDate.arrangeNum(year,month,date); yearModel=newSpinnerNumberModel(year,0,10000,1); showYear=newJSpinner(yearModel); //showYear.addChangeListener(this); showYear.setEditor(newJSpinner.NumberEditor(showYear,"0000")); y1.setFont(newFont("TimesRonmn",Font.BOLD,16)); monthModel=newSpinnerNumberModel(month,1,12,1); showMonth=newJSpinner(monthModel); //showMonth.addChangeListener(this); m1.setFont(newFont("TimesRonmn",Font.BOLD,16)); dateModel=newSpinnerNumberModel(date,1,31,1); showDate=newJSpinner(dateModel); //showDate.addChangeListener(this); d1.setFont(newFont("TimesRonmn",Font.BOLD,16)); }}classDateTime//時(shí)間的設(shè)置{ publicstaticintyear; publicstaticintmonth; publicstaticintdate; publicCalendarc; DateTime() { c=Calendar.getInstance(); year=c.get(c.YEAR); month=c.get(c.MONTH)+1; date=c.get(c.DATE); } DateTime(inti){} publicintgetYear() { returnyear; } publicintgetMonth() { returnmonth; } publicintgetDate() { returndate; } publicintgetMonday(intyear,intmonth) { if(((year%4==0&&year%100!=0)||year%400==0)&&month==2) { return29; } elseif(month==1||month==3||month==5||month==7||month==8||month==10||month==12) { return31; } elseif(month==2) { return28; } else { return30; } } }classFontPopupextendsJPopupMenuimplementsActionListener//文本框字體的設(shè)置{ Stringitem[]; Fontfont[]; JMenuItemmt; JTextAreat; FontPopup(JTextAreat) { this.t=t; //this.setBorder(newBevelBorder(BevelBorder.RAISED)); item=newString[]{"標(biāo)準(zhǔn)仿宋","粗放行楷","規(guī)矩新魏","精致宋體","靈感隸書"}; font=newFont[]{ newFont("仿宋",0,18), newFont("華文行楷",0,30), newFont("華文新魏",0,22), newFont("宋體",0,14), newFont("隸書",0,18), }; for(inti=0;i<item.length;i++) { mt=newJMenuItem(item[i]); mt.setFont(newFont("仿宋",0,14)); this.add(mt); mt.addActionListener(this); }} publicvoidactionPerformed(ActionEvente) { Stringstr=e.getActionCommand(); inti; for(i=0;i<item.length;i++) if(str.equals(item[i]))break; t.setFont(font[i]); } } classNoteBookextendsJFrameimplementsActionListener,MouseListener,ChangeListener{ JTextAreatxt; JPanelp1; JLabelpic; JLabellabTxt; Containercont; JButtonbtnSave; JButtonbtnDelete; JButtonbtnInput; JButtonbtnOutput; JScrollPanejsp; Stringpass; Hashtabletable; Datekey; SimpleDateFormatsimDate; FilenoteFile; FileInputStreamnoteFileIn; staticFontsaveFont;//保存顏色 SexBoxsexBox; YearMonthyearMonth=newYearMonth(); AreaDateare; Weekweek; FontPopupfp;//設(shè)置字體// Enterword=newEnter(1); DateTimedateTime=newDateTime(1); NoteBook() { super("寫字留痕V4.0bydaming"); this.setResizable(false); this.setDefaultCloseOperation(3); this.setBounds(300,100,800,600);// ymInit(); init(); this.setVisible(true); } NoteBook(inti){} publicvoidinit() { cont=this.getContentPane(); cont.setBackground(Color.blue); cont.setLayout(null); p1=newJPanel(); p1.setLayout(newGridLayout(1,3,5,5)); txt=newJTextArea(); txt.setLineWrap(true); //txt.setText((String)(table.get(20111124))); pic=newJLabel(newImageIcon("1.jpg")); btnSave=newJButton("保存"); btnDelete=newJButton("刪除"); btnInput=newJButton("導(dǎo)入"); btnOutput=newJButton("導(dǎo)出"); sexBox=newSexBox();//定義選取天氣 are=newAreaDate();//定義萬(wàn)年歷放置的文本// yearMonth=newYearMonth();//定義選取時(shí)間 week=newWeek();//定義星期 jsp=newJScrollPane(txt); noteFile=newFile(Integer.toString(dateTime.year)+Integer.toString(dateTime.month) +Integer.toString(dateTime.date)+".txt"); simDate=newSimpleDateFormat("yyyyMMdd"); try{ key=simDate.parse(Integer.toString(dateTime.year)+Integer.toString(dateTime.month) +Integer.toString(dateTime.date)); } catch(Exceptione){} fp=newFontPopup(txt);//設(shè)置字體類 saveFont=newFont("宋體",0,18); labTxt=newJLabel(Integer.toString(dateTime.year)+"年"+ Integer.toString(dateTime.month)+"月"+Integer.toString(dateTime.date)+"日" );//定義時(shí)間的標(biāo)簽在多文本的上面 labTxt.setFont(newFont("宋體",Font.BOLD,20)); p1.add(btnSave); p1.add(btnDelete); p1.add(btnInput); p1.add(btnOutput); cont.add(p1); cont.add(jsp); cont.add(sexBox); cont.add(are); cont.add(yearMonth); //cont.add(are); cont.add(week); cont.add(pic); cont.add(labTxt); jsp.setBounds(250,50,530,450);//記事本位置 p1.setBounds(320,530,300,30);//3個(gè)按鈕面板 yearMonth.setBounds(0,510,260,30);//時(shí)間選取組件位置 sexBox.setBounds(600,15,200,35);//天氣選取組件位置 are.setBounds(0,300,250,200);//日期文本框位置 week.setBounds(0,270,260,30);//星期位置 pic.setBounds(5,40,240,240);//圖片位置 labTxt.setBounds(350,5,250,50); btnSave.addActionListener(this); btnDelete.addActionListener(this); btnInput.addActionListener(this); btnOutput.addActionListener(this); txt.addMouseListener(this); for(inti=0;i<42;i++) are.showDay[i].addMouseListener(this); yearMonth.showYear.addChangeListener(this); yearMonth.showMonth.addChangeListener(this); yearMonth.showDate.addChangeListener(this); fileReader(); }publicvoidstateChanged(ChangeEvente){ dateTime.year=(Integer)yearMonth.showYear.getModel().getValue(); dateTime.month=(Integer)yearMonth.showMonth.getModel().getValue(); dateTime.date=(Integer)yearMonth.showDate.getModel().getValue(); System.out.println(dateTime.year); saveFile(); //newAreaDate(); newNoteBook(); this.dispose();}publicvoidactionPerformed(ActionEvente)//控件偵聽(tīng) { if(e.getSource()==btnOutput) outputFile(); elseif(e.getSource()==btnInput) inputFile(); elseif(e.getSource()==btnDelete) deleteFile(); elseif(e.getSource()==btnSave) { saveFile(); JOptionPane.showMessageDialog(null,"保存成功"); } } publicvoidoutputFile()//導(dǎo)出文件 { pass=JOptionPane.showInputDialog("youkey?"); if(!pass.equals("321")) { JOptionPane.showMessageDialog(newJDialog(),"抱歉,你無(wú)權(quán)導(dǎo)出"); } else { JFileChooserfc=newJFileChooser("E:\\日記"); fc.showSaveDialog(this); Filefile=fc.getSelectedFile(); try { FileWriterout=newFileWriter(file); out.write(txt.getText()); out.close(); } catch(Exceptione) {} //pass=JOptionPane.showInputDialog("youkey?"); } } publicvoidinputFile()//導(dǎo)入文件 { JFileChooserfc=newJFileChooser("E:\\日記"); fc.showOpenDialog(this); Filefile=fc.getSelectedFile(); try { FileInputStreamin=newFileInputStream(file); byteb[]=newbyte[in.available()]; in.read(b); txt.setText(newString(b)); in.close(); } catch(Exceptione){} } publicvoiddeleteFile() { Objectobj=JOptionPane.showConfirmDialog(null,"是否要?jiǎng)h除這天的記錄?"); ObjectobjTest=0; if(obj==objTest) { txt.setText(""); } } publicvoidsaveFile()//保存文件 { try{ /*ObjectOutputStreamobjectOut=newObjectOutputStream(newFileOutputStream( Integer.toString(dateTime.year)+Integer.toString(dateTime.month) +Integer.toString(dateTime.date)+".txt")); objectOut.writeObject(table); objec

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論