




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上NIIT2綜合訓(xùn)練日歷記事本專業(yè)計(jì)算機(jī)科學(xué)與技術(shù)學(xué)生姓名班級(jí)學(xué)號(hào)指導(dǎo)教師完成日期信息工程學(xué)院專心-專注-專業(yè)目 錄NIIT2綜合訓(xùn)練一、綜合訓(xùn)練的目的(1) 進(jìn)一步鞏固所學(xué)的Java語(yǔ)言基礎(chǔ)知識(shí),達(dá)到熟練編寫、運(yùn)用的程度;(2) 鍛煉自己的面向?qū)ο蟮某绦蛟O(shè)計(jì)思想,能夠深刻認(rèn)識(shí)面向過(guò)程與面向?qū)ο髢煞N設(shè)計(jì)方法之間的區(qū)別;(3) 熟練掌握具體軟件開發(fā)平臺(tái)下(NetBeans)的動(dòng)手能力,掌握J(rèn)ava應(yīng)用程序設(shè)計(jì)的方法與技巧,實(shí)現(xiàn)從傳統(tǒng)面向過(guò)程程序設(shè)計(jì)思維到面向?qū)ο蟪绦蛟O(shè)計(jì)思維的轉(zhuǎn)型;(4) 初步了解MIS的概念與相關(guān)知識(shí),具備獨(dú)立設(shè)計(jì)、實(shí)現(xiàn)小型MIS系統(tǒng)的應(yīng)用開發(fā)能力。二、
2、綜合訓(xùn)練的內(nèi)容題目:日歷記事本三、綜合訓(xùn)練的具體實(shí)現(xiàn)1設(shè)計(jì)內(nèi)容 設(shè)計(jì)GUI界面的日歷記事本。系統(tǒng)將日歷,記事本功能結(jié)合在一起,用戶可以方便地在任何日期記錄下有關(guān)內(nèi)容或查看某個(gè)日期的記錄內(nèi)容。2設(shè)計(jì)要求 1.系統(tǒng)界面的左側(cè)是日歷。該日歷可以按年份前后翻動(dòng),鼠標(biāo)單擊“上年”按鈕時(shí),當(dāng)前日歷的年份減一;當(dāng)鼠標(biāo)左鍵單擊“下年”按鈕,當(dāng)前日歷的年份加一。 2.該日歷也可以在某年內(nèi)按月前后翻動(dòng)。鼠標(biāo)單擊“上月”按鈕時(shí),當(dāng)前日歷的月份減一;當(dāng)鼠標(biāo)左鍵單擊“下月”按鈕,當(dāng)前日歷表的月份加一。 3.使用鼠標(biāo)左鍵單擊選定的日期,如已有記錄內(nèi)容,系統(tǒng)將彈出對(duì)話框提示該日歷已有記錄內(nèi)容,并詢問(wèn)用戶是否用記事本顯示該內(nèi)
3、容。 4.用戶選擇具體日期后,可以將記事本的當(dāng)前內(nèi)容保存起來(lái),形成日志。3總體設(shè)計(jì) 本日歷記事本程序共有4個(gè)java源文件。CalendarPad.java該java文件生成的類負(fù)責(zé)創(chuàng)建本日歷記事本程序主窗口。該類含有main方法,程序從該類開始執(zhí)行。Year.java該文件負(fù)責(zé)創(chuàng)建管理年份的對(duì)象。Momth.java該文件負(fù)責(zé)創(chuàng)建管理月份的類對(duì)象。NotePad.java該文件負(fù)責(zé)創(chuàng)建記事本。4具體設(shè)計(jì)運(yùn)行效果與程序發(fā)布1. 將4個(gè)java文件保存到一個(gè)文件夾中。將4個(gè)文件分別編譯生成相應(yīng)的字節(jié)碼文件。然后,用java解釋器運(yùn)行主類,效果如圖: 2.可以使用jar.exe把一些文件壓縮成JA
4、R文件,來(lái)發(fā)布我們的應(yīng)用程序??梢园驯緅ava應(yīng)用程序中涉及到的類文件壓縮成一個(gè)JAR文件,例如CalendarPad.jar. 首先,用文本編輯器編寫一個(gè)清單文件,然后,如下生成JAR文件: C:notepadjar cfm CalendarPad.jar moon.mf *.class 其中,參數(shù)c表示要生成一個(gè)新的JAR文件;f表示要生成的JAR文件的名字;m表示清單文件的名字。現(xiàn)在皆就可以將Calendar.Jar拷貝到任何一個(gè)安裝了java運(yùn)行環(huán)境的計(jì)算機(jī)上,只要用鼠標(biāo)雙擊文件就可以運(yùn)行本java應(yīng)用程序了。 另外創(chuàng)建一個(gè)幫助文件help.txt,內(nèi)容如下:您可以用鼠標(biāo)雙擊Calen
5、darPad.jar或CalendarPad.bat來(lái)運(yùn)行本軟件,但是,如果您的計(jì)算機(jī)上安裝了中文版WinRAR解壓縮軟件,并將.jar文件與該解壓縮軟件做了關(guān)聯(lián),那么,用鼠標(biāo)雙擊CalendarPar.jar文件時(shí),WinRAR解壓縮軟件會(huì)自動(dòng)運(yùn)行進(jìn)行解壓縮操作,這時(shí)您可以雙擊Calendar.Pad.bat來(lái)運(yùn)行我們的軟件。 最后,將.bat文件,.jar文件,幫助文件一同發(fā)布。四、綜合訓(xùn)練的總結(jié)經(jīng)過(guò)一個(gè)學(xué)期的JAVA學(xué)習(xí),我對(duì)JAVA編程有了一定的認(rèn)識(shí),在做這個(gè)課程設(shè)計(jì)的時(shí)候,剛開始感覺(jué)自己無(wú)從下手,不知道該怎么開始,很茫然。最終利用網(wǎng)絡(luò)資源和查閱圖書館的書籍,在傅老師和同學(xué)的指導(dǎo)和討論
6、下,經(jīng)過(guò)一段時(shí)間終于完成了這個(gè)設(shè)計(jì)。當(dāng)程序運(yùn)行結(jié)束看到彈出的日歷記事本的界面時(shí),感到很欣慰,雖然只是一個(gè)小小的東西,但卻是自己起步的成就,從中學(xué)到了很多書本知識(shí)不能體現(xiàn)的東西,對(duì)JAVA的學(xué)習(xí)有了一定的興趣。也通過(guò)這次的程序設(shè)計(jì)感覺(jué)到自己平時(shí)對(duì)于編程實(shí)際操作的貧乏,沒(méi)有把書本上的知識(shí)真正的掌握牢固。以后要多動(dòng)手做才會(huì)有收獲。附錄:源程序清單CalendarPad.javaimport java.util.Calendar;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.io.*;import
7、java.util.Hashtable;public class CalendarPad extends JFrame implements MouseListener int year,month,day; Hashtable hashtable; File file; JTextField showDay; JLabel title; Calendar 日歷; int 星期幾; NotePad notepad=null; Month 負(fù)責(zé)改變?cè)? Year 負(fù)責(zé)改變年; String 星期="星期日","星期一","星期二",&q
8、uot;星期三","星期四","星期五","星期六" JPanel leftPanel,rightPanel; public CalendarPad(int year,int month,int day) leftPanel=new JPanel(); JPanel leftCenter=new JPanel(); JPanel leftNorth=new JPanel(); leftCenter.setLayout(new GridLayout(7,7); rightPanel=new JPanel(); this.yea
9、r=year; this.month=month; this.day=day; 負(fù)責(zé)改變年=new Year(this); 負(fù)責(zé)改變年.setYear(year); 負(fù)責(zé)改變?cè)?new Month(this); 負(fù)責(zé)改變?cè)?setMonth(month); title=new JLabel7; showDay=new JTextField42; for(int j=0;j<7;j+) titlej=new JLabel(); titlej.setText(星期j); titlej.setBorder(BorderFactory.createRaisedBevelBorder(); lef
10、tCenter.add(titlej); title0.setForeground(Color.red); title6.setForeground(Color.blue); for(int i=0;i<42;i+) showDayi=new JTextField(); showDayi.addMouseListener(this); showDayi.setEditable(false); leftCenter.add(showDayi); 日歷=Calendar.getInstance(); Box box=Box.createHorizontalBox(); box.add(負(fù)責(zé)改
11、變年); box.add(負(fù)責(zé)改變?cè)?; leftNorth.add(box); leftPanel.setLayout(new BorderLayout(); leftPanel.add(leftNorth,BorderLayout.NORTH); leftPanel.add(leftCenter,BorderLayout.CENTER); leftPanel.add(new Label("請(qǐng)?jiān)谀攴葺斎肟蜉斎胨槟攴?負(fù)數(shù)表示公元前),并回車確定"), BorderLayout.SOUTH) ; leftPanel.validate(); Container con=ge
12、tContentPane(); JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel,rightPanel); con.add(split,BorderLayout.CENTER); con.validate(); hashtable=new Hashtable(); file=new File("日歷記事本.txt"); if(!file.exists() try FileOutputStream out=new FileOutputStream(file); ObjectOutput
13、Stream objectOut=new ObjectOutputStream(out); objectOut.writeObject(hashtable); objectOut.close(); out.close(); catch(IOException e) notepad=new NotePad(this); rightPanel.add(notepad); 設(shè)置日歷牌(year,month); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); )
14、; setVisible(true); setBounds(100,50,524,285); validate(); public void 設(shè)置日歷牌(int year,int month) 日歷.set(year,month-1,1); 星期幾=日歷.get(Calendar.DAY_OF_WEEK)-1; if(month=1|month=2|month=3|month=5|month=7 |month=8|month=10|month=12) 排列號(hào)碼(星期幾,31); else if(month=4|month=6|month=9|month=11) 排列號(hào)碼(星期幾,30); el
15、se if(month=2) if(year%4=0&&year%100!=0)|(year%400=0) 排列號(hào)碼(星期幾,29); else 排列號(hào)碼(星期幾,28); public void 排列號(hào)碼(int 星期幾,int 月天數(shù)) for(int i=星期幾,n=1;i<星期幾+月天數(shù);i+) showDayi.setText(""+n); if(n=day) showDayi.setForeground(Color.green); showDayi.setFont(new Font("TimesRoman",Font.B
16、OLD,20); else showDayi.setFont(new Font("TimesRoman",Font.BOLD,12); showDayi.setForeground(Color.black); if(i%7=6) showDayi.setForeground(Color.blue); if(i%7=0) showDayi.setForeground(Color.red); n+; for(int i=0;i<星期幾;i+) showDayi.setText(""); for(int i=星期幾+月天數(shù);i<42;i+) sho
17、wDayi.setText(""); public int getYear() return year; public void setYear(int y) year=y; notepad.setYear(year); public int getMonth() return month; public void setMonth(int m) month=m; notepad.setMonth(month); public int getDay() return day; public void setDay(int d) day=d; notepad.setDay(d
18、ay); public Hashtable getHashtable() return hashtable; public File getFile() return file; public void mousePressed(MouseEvent e) JTextField source=(JTextField)e.getSource(); try day=Integer.parseInt(source.getText(); notepad.setDay(day); notepad.設(shè)置信息條(year,month,day); notepad.設(shè)置文本區(qū)(null); notepad.獲取
19、日志內(nèi)容(year,month,day); catch(Exception ee) public void mouseClicked(MouseEvent e) public void mouseReleased(MouseEvent e) public void mouseEntered(MouseEvent e) public void mouseExited(MouseEvent e) public static void main(String args) Calendar calendar=Calendar.getInstance(); int y=calendar.get(Cale
20、ndar.YEAR); int m=calendar.get(Calendar.MONTH)+1; int d=calendar.get(Calendar.DAY_OF_MONTH); new CalendarPad(y,m,d); Year.javaMonth.javaNote.javaYear.javaimport javax.swing.*;import java.awt.*;import java.awt.event.*;public class Year extends Box implements ActionListener int year; int month; JTextF
21、ield showYear=null; JButton 明年,去年; CalendarPad 日歷; public Year(CalendarPad 日歷) super(BoxLayout.X_AXIS); showYear=new JTextField(4); showYear.setForeground(Color.blue); showYear.setFont(new Font("TimesRomn",Font.BOLD,14); this.日歷=日歷; year=日歷.getYear(); 明年=new JButton("下年"); 去年=new
22、 JButton("上年"); add(去年); add(showYear); add(明年); showYear.addActionListener(this); 去年.addActionListener(this); 明年.addActionListener(this); public void setYear(int year) this.year=year; showYear.setText(""+year); public int getYear() return year; public void actionPerformed(Action
23、Event e) if(e.getSource()=去年) year=year-1; showYear.setText(""+year); 日歷.setYear(year); 日歷.設(shè)置日歷牌(year,日歷.getMonth(); else if(e.getSource()=明年) year=year+1; showYear.setText(""+year); 日歷.setYear(year); 日歷.設(shè)置日歷牌(year,日歷.getMonth(); else if(e.getSource()=showYear) try year=Integer.p
24、arseInt(showYear.getText(); showYear.setText(""+year); 日歷.setYear(year); 日歷.設(shè)置日歷牌(year,日歷.getMonth(); catch(NumberFormatException ee) showYear.setText(""+year); 日歷.setYear(year); 日歷.設(shè)置日歷牌(year,日歷.getMonth(); Month.javaimport javax.swing.*;import java.awt.*;import java.awt.event.*
25、;public class Month extends Box implements ActionListener int month; JTextField showMonth=null; JButton 下月,上月; CalendarPad 日歷; public Month(CalendarPad 日歷) super(BoxLayout.X_AXIS); this.日歷=日歷; showMonth=new JTextField(2); month=日歷.getMonth(); showMonth.setEditable(false); showMonth.setForeground(Col
26、or.blue); showMonth.setFont(new Font("TimesRomn",Font.BOLD,16); 下月=new JButton("下月"); 上月=new JButton("上月"); add(上月); add(showMonth); add(下月); 上月.addActionListener(this); 下月.addActionListener(this); showMonth.setText(""+month); public void setMonth(int month) i
27、f(month<=12&&month>=1) this.month=month; else this.month=1; showMonth.setText(""+month); public int getMonth() return month; public void actionPerformed(ActionEvent e) if(e.getSource()=上月) if(month>=2) month=month-1; 日歷.setMonth(month); 日歷.設(shè)置日歷牌(日歷.getYear(),month); else i
28、f(month=1) month=12; 日歷.setMonth(month); 日歷.設(shè)置日歷牌(日歷.getYear(),month); showMonth.setText(""+month); else if(e.getSource()=下月) if(month<12) month=month+1; 日歷.setMonth(month); 日歷.設(shè)置日歷牌(日歷.getYear(),month); else if(month=12) month=1; 日歷.setMonth(month); 日歷.設(shè)置日歷牌(日歷.getYear(),month); showMo
29、nth.setText(""+month); NotePad.javaimport java.awt.*;import java.awt.event.*;import java.util.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;public class NotePad extends JPanel implements ActionListener JTextArea text; JButton 保存日志,刪除日志; Hashtable table; JLabel 信息條; int
30、 year,month,day; File file; CalendarPad calendar; public NotePad(CalendarPad calendar) this.calendar=calendar; year=calendar.getYear(); month=calendar.getMonth(); day=calendar.getDay(); table=calendar.getHashtable(); file=calendar.getFile(); 信息條=new JLabel(""+year+"年"+month+"
31、;月"+day+"日",JLabel.CENTER); 信息條.setFont(new Font("TimesRoman",Font.BOLD,16); 信息條.setForeground(Color.blue); text=new JTextArea(10,10); 保存日志=new JButton("保存日志") ; 刪除日志=new JButton("刪除日志") ; 保存日志.addActionListener(this); 刪除日志.addActionListener(this); setLay
32、out(new BorderLayout(); JPanel pSouth=new JPanel(); add(信息條,BorderLayout.NORTH); pSouth.add(保存日志); pSouth.add(刪除日志); add(pSouth,BorderLayout.SOUTH); add(new JScrollPane(text),BorderLayout.CENTER); public void actionPerformed(ActionEvent e) if(e.getSource()=保存日志) 保存日志(year,month,day); else if(e.getSo
33、urce()=刪除日志) 刪除日志(year,month,day); public void setYear(int year) this.year=year; public int getYear() return year; public void setMonth(int month) this.month=month; public int getMonth() return month; public void setDay(int day) this.day=day; public int getDay() return day; public void 設(shè)置信息條(int yea
34、r,int month,int day) 信息條.setText(""+year+"年"+month+"月"+day+"日"); public void 設(shè)置文本區(qū)(String s) text.setText(s); public void 獲取日志內(nèi)容(int year,int month,int day) String key=""+year+""+month+""+day; try FileInputStream inOne=new FileInp
35、utStream(file); ObjectInputStream inTwo=new ObjectInputStream(inOne); table=(Hashtable)inTwo.readObject(); inOne.close(); inTwo.close(); catch(Exception ee) if(table.containsKey(key) String m=""+year+"年"+month+"月"+day+"這一天有日志記載,想看嗎?" int ok=JOptionPane.showCon
36、firmDialog(this,m,"詢問(wèn)",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if(ok=JOptionPane.YES_OPTION) text.setText(String)table.get(key); else text.setText(""); else text.setText("無(wú)記錄"); public void 保存日志(int year,int month,int day) String 日志內(nèi)容=text.getText(); S
37、tring key=""+year+""+month+""+day; String m=""+year+"年"+month+"月"+day+"保存日志嗎?" int ok=JOptionPane.showConfirmDialog(this,m,"詢問(wèn)",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if(ok=JOptionPane.YES_OPTION) try FileInputStream inOne=new FileInputStream(file); ObjectInputStream inTwo=new Obj
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 手車交易服務(wù)協(xié)議書
- 2024年襄陽(yáng)市中醫(yī)醫(yī)院招聘急需專業(yè)技術(shù)人才考試真題
- 2024年酒泉市省屬公費(fèi)師范畢業(yè)生專項(xiàng)招聘考試真題
- 2025年DDN線路密碼機(jī)項(xiàng)目發(fā)展計(jì)劃
- 工藝品購(gòu)銷協(xié)議書
- 產(chǎn)品生產(chǎn)承包協(xié)議合同
- 農(nóng)民經(jīng)濟(jì)合作組織章程及協(xié)議規(guī)定書
- 場(chǎng)地使用租賃合同租賃合同
- 店面空地租賃協(xié)議
- 房屋轉(zhuǎn)租三方協(xié)議書
- 石化行業(yè)智能化升級(jí)行業(yè)深度調(diào)研及發(fā)展戰(zhàn)略咨詢報(bào)告
- 磚砌圍墻工程施工方案
- 兒童衛(wèi)生習(xí)慣的養(yǎng)成與學(xué)校教育的結(jié)合
- 手術(shù)室煙霧試題及答案
- 2024年風(fēng)景園林專業(yè)中級(jí)職稱《專業(yè)知識(shí)》考試題庫(kù)(含答案)
- 精神疾病的防治知識(shí)宣傳課件
- 大學(xué)生心理健康 第8章-教學(xué)教案-愛(ài)情心理
- 2025年前期物業(yè)管理中的法律法規(guī)解讀與應(yīng)用
- 2025年河南工業(yè)職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)傾向性測(cè)試題庫(kù)1套
- 1.2 思維形態(tài)及其特征 課件-高中政治統(tǒng)編版選擇性必修三邏輯與思維
- 鋼結(jié)構(gòu)廠房承包合同范本
評(píng)論
0/150
提交評(píng)論