


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、JAVA程序設(shè)計(jì)課程設(shè)計(jì)報(bào)告專業(yè):信息管理與信息系統(tǒng)班級(jí):1124602學(xué)號(hào):2姓名:鄒瑋指導(dǎo)教師:姜俊坡目錄1 可行性分析 22 .需求分析功能23 .課程設(shè)計(jì)24. 編碼 35. 系統(tǒng)驗(yàn)證21216. 總結(jié)1. 可行性分析1. 學(xué)習(xí)Java程序開發(fā)的環(huán)境搭建與配置,并且在實(shí)際運(yùn)用中學(xué)習(xí)和和掌握 Java程序開發(fā)的過程2. 通過課程設(shè)計(jì)進(jìn)一步掌握J(rèn)ava程序設(shè)計(jì)語言的基礎(chǔ)內(nèi)容,如用戶圖形界 面設(shè)計(jì)等3通過親自設(shè)計(jì),編寫,調(diào)試程序來擴(kuò)展知識(shí)面和動(dòng)手操作能力2. 需求分析功能設(shè)計(jì)一個(gè)日歷記事本.具體要求如下:1. 可以設(shè)置日歷的日期2. 可以判斷當(dāng)前日期是否有日志記錄3. 對(duì)有日志記錄的日期,可
2、以對(duì)該日期的日志記錄進(jìn)行修改和刪除4. 對(duì)沒有日志記錄的日期,可以創(chuàng)建并保存新建的日志記錄3. 課程設(shè)計(jì)表1日歷記事本系統(tǒng)主面板與日歷板模塊(Cale ndarPad.java類名Cale ndarPadpublic接口MouseListe nerpublicCale ndarPad(i nt, in t,i ntpublic方法設(shè)置日歷牌(int,intpublic void排列號(hào)碼(int,intpublic voidmain (public static void表2日歷記事本系統(tǒng)年設(shè)置模塊 (Year.java類名Yearpublic接口Actio nListe nerpublicse
3、tYear(public void方法getYear(public intactio nPeformed(Actio nEve nt epublic void表3日歷記事本系統(tǒng)月設(shè)置模塊(Month.java類名Mon thpublic接口Actio nListe nerpublicsetM on th(public void方法getM on th(public intactio nPeformed(Actio nEve nt epublic void表4日歷記事本系統(tǒng)記事本模塊(NotePad.java類名NotePadpublic接口Actio nListe nerpublic設(shè)置信息條
4、(public void設(shè)置文本區(qū)(public void方法獲取日志內(nèi)容(public void保存日志(public void刪除日志(public void4. 編碼1.日歷記事本系統(tǒng)主面板與日歷板模塊(CalendarPad.java該模塊設(shè)計(jì)主要主要包含以下成員變量:年(year月(month日(day存放日期的表 (Hashtable 存放日志的文件 (File主要方法有: 創(chuàng)建程序主面板的構(gòu)造方法 CalendarPad ) 處理 ActionEvent 事件的接口方法 actionPerformed ) 程序開始運(yùn)行的 main leftPanel=new JPanel( 。
5、JPanel leftCenter=new JPanel( 。 JPanel leftNorth=new JPanel( 。 leftCenter.setLayout(new GridLayout(7,7 。rightPanel=new JPanel( 。 this.year=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
6、=new JTextField42 。for(int j=0。 jtitlej=new JLabel( 。titlej.setText(星期j。titlej.setBorder(BorderFactory.createRaisedBevelBorder( 。leftCenter.add(titlej 。title0.setForeground(Color.red 。 title6.setForeground(Color.blue 。 for(int i=0 。 ishowDayi=new JTextField( 。 showDayi.addMouseListener(this 。 showDa
7、yi.setEditable(false 。 leftCenter.add(showDayi 。日歷 =Calendar.getInstance( 。Box box=Box.createHorizontalBox( 。box.add( 負(fù)責(zé)改變年 。 box.add( 負(fù)責(zé)改變?cè)?。leftNorth.add(box 。 leftPanel.setLayout(new BorderLayout( 。 leftPanel.add(leftNorth,BorderLayout.NORTH 。 leftPanel.add(leftCenter,BorderLayout.CENTER 。 leftPa
8、nel.add(new Label( 請(qǐng)?jiān)谀攴葺斎肟蜉斎胨槟攴?負(fù)數(shù)表示公元前 ,并回車確定 ,BorderLayout.SOUTH 。leftPanel.validate( 。Container con=getContentPane( 。JSplitPane split=newJSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel,rightPanel con.add(split,BorderLayout.CENTER 。 con.validate( 。hashtable=new Hashtable( 。file=new File( 日歷記事本 .
9、txt 。if(!file.exists(tryFileOutputStream out=newFileOutputStream(file 。ObjectOutputStream objectOut=newObjectOutputStream(out 。objectOut.writeObject(hashtable 。objectOut.close( 。 out.close( 。catch(IOException enotepad=new NotePad(this 。rightPanel.add(notepad 。設(shè)置日歷牌 (year,month 。addWindowListener(new
10、 WindowAdapter(public void windowClosing(WindowEvent eSystem.exit(0 。setVisible(true 。setBounds(100,50,524,285 。validate( 。public void 設(shè)置日歷牌 (int year,int month日歷 .set(year,month-1,1 。星期幾二日歷.get(Cale ndar.DAY_0F_WEEK-1 。if(month=1|month=2|month=3|month=5|month=7|month=8|month=10|month=12排列號(hào)碼(星期幾,31。
11、elseif(month=4|month=6|month=9|month=11排列號(hào)碼(星期幾,30。else if(month=2if(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。ishowDayi.setText(+nif(n=dayshowDayi.setForeground(Color.green 。showDayi.setFont(new Font(TimesRoman,Font.BOLD,20 。 el
12、seshowDayi.setFont(new Font(TimesRoman,Font.BOLD,12 。showDayi.setForeground(Color.black 。 if(i%7=6showDayi.setForeground(Color.blue 。 if(i%7=0showDayi.setForeground(Color.red 。 n+。for(int i=0。ishowDayi.setText( 。 for(int i= 星期幾 +月天數(shù)。 ishowDayi.setText( 。 public int getYear(return year 。 public void
13、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(day 。 public Hashtable getHashtable(return hashtable 。 public File getFile(ret
14、urn file 。public void mousePressed(MouseEvent e JTextField source=(JTextFielde.getSource(tryday=Integer.parseInt(source.getText( 。 notepad.setDay(day 。 notepad. 設(shè)置信息條 (year,month,day 。 notepad. 設(shè)置文本區(qū) (null 。 notepad. 獲取日志內(nèi)容 (year,month,day 。 catch(Exception eepublic void mouseClicked(MouseEve nt epu
15、blic void mouseReleased(MouseEve nt e public void mouseEntered(MouseEvent e public void mouseExited(MouseEvent e public static void main(String argsCalendar calendar=Calendar.getInstance( 。 int y=calendar.get(Calendar.YEAR 。 int m=calendar.get(Calendar.MONTH+1 。 int d=calendar.get(Calendar.DAY_OF_MO
16、NTH 。 new CalendarPad(y,m,d 。2. 日歷記事本系統(tǒng)年設(shè)置模塊 (Year.java 該模塊用于實(shí)現(xiàn)日歷記事本系統(tǒng)中關(guān)于年的設(shè)置 模塊中包含的主要成員變量有用于改變年的按鈕 (Jbutton 明年 去年 ,顯 示年的文本框 (JTextField模塊中包含的主要方法有用于設(shè)置年的方法 (setYear, 用于獲取年的方 法(getYear 和處理 ActionEvent 事件的接口方法(actionPeformed 等 實(shí)現(xiàn)編碼如下 :import javax.swing.* 。import java.awt.* 。import java.awt.event.* 。p
17、ublic class Year extends Box implements ActionListenerint year 。JTextField 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. 日歷=日歷。yea
18、r=日歷.getYear(。明年=new JButton(” 下年。去年 =new JButton( 上年。add(去年。add(showYear 。add(明年。showYear.addActionListener(this 。去年 .addActionListener(this 。明年.addActionListener(this 。public void setYear(int yearthis.year=year 。showYear.setText(+year 。public int getYear(return year 。public void actionPerformed(Ac
19、tionEvent eif(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(=showYeartryyear=Integer.parseInt(showYear.getText( 。
20、showYear.setText(+year 。 日歷 .setYear(year 。日歷 .設(shè)置日歷牌 (year, 日歷 .getMonth( 。 catch(NumberFormatException eeshowYear.setText(+year 。 日歷 .setYear(year 。 日歷 .設(shè)置日歷牌 (year, 日歷 .getMonth( 。 3. 日歷記事本系統(tǒng)月設(shè)置模塊 (Month.java該模塊用于實(shí)現(xiàn)日歷記事本系統(tǒng)中關(guān)于月的設(shè)置 模塊中包含的主要成員變量有用于改變?cè)碌陌粹o (Jbutton 上月 下月,顯 示月的文本框 (JTextField模塊中包含的主要方法有
21、用于設(shè)置月的方法 (setMonth, 用于獲取月的方法(getMonth 和處理 ActionEvent 事件的接口方法(actionPeformed 等 實(shí)現(xiàn)編碼如下 :import javax.swing.import java.awt.* 。import java.awt.event.* 。public class Month extends Box implements ActionListenerint month 。JTextField showMonth=null 。JButton 下月 ,上月。CalendarPad 日歷。public Month(CalendarPad 日
22、歷 super(BoxLayout.X_AXIS 。this. 日歷=日歷。showMonth=new JTextField(2 。month= 日歷 .getMonth( 。showMonth.setEditable(false 。 showMonth.setForeground(Color.blue 。showMonth.setFont(new Font(TimesRomn,Font.BOLD,16 下月=new JButton(” 下月。上月 =new JButton( 上月 。add( 上月 。add(showMonth 。add( 下月 。上月 .addActionListener(
23、this下月 .addActionListener(this 。 showMonth.setText(+month 。public void setMonth(int monthif(month=1this.month=month 。elsethis.month=1 。showMonth.setText(+month 。public int getMonth(return month 。public void actionPerformed(ActionEvent e if(e.getSource(= 上月 if(month=2month=month-1 。日歷 .setMonth(month
24、 。日歷.設(shè)置日歷牌 (日歷 .getYear(,month else if(month=1month=12 。日歷 .setMonth(month 。日歷.設(shè)置日歷牌 (日歷 .getYear(,month showMonth.setText(+month 。else if(e.getSource(= 下月 if(monthmonth=month+1 。日歷 .setMonth(month 。日歷.設(shè)置日歷牌 (日歷 .getYear(,month 。else if(month=12month=1 。日歷 .setMonth(month 。 日歷.設(shè)置日歷牌 (日歷 .getYear(,mo
25、nth 。 showMonth.setText(+month 。4. 日歷記事本系統(tǒng)記事本模塊 (NotePad.java 該模塊中包含的主要成員變量有文本框 (JTextArea, 按鈕 (JButton 保存 日志 刪除日志 ,用于存放日志記錄的文件 (File 以及響應(yīng)相關(guān)操作的信息提示 (JLabel該模塊中包含的主要方法有設(shè)置信息條 ,設(shè)置文本區(qū) ,獲取日志內(nèi)容 ,保存 日志,刪除日志實(shí)現(xiàn)編碼如下 :import java.awt.* 。import java.awt.event.* 。import java.util.* 。import javax.swing.* 。import
26、javax.swing.event.* 。import java.io.* 。public class NotePad extends JPanel implements ActionListenerJTextArea text 。JButton 保存日志 ,刪除日志。Hashtable table 。JLabel 信息條。int year,month,day 。File file 。CalendarPad calendar 。public NotePad(CalendarPad calendarthis.calendar=calendar 。 year=calendar.getYear( 。
27、 month=calendar.getMonth( 。 day=calendar.getDay( 。 table=calendar.getHashtable( 。 file=calendar.getFile( 。信息條=new JLabel(+year+年+month+月+day+日,JLabel.CENTER 。信息條 .setFont(new Font(TimesRoman,Font.BOLD,16 信息條 .setForeground(Color.blue 。text=new JTextArea(10,10 。保存日志 =new JButton( 保存日志 。 刪除日志 =new JBu
28、tton( 刪除日志 。 保存日志 .addActionListener(this 。 刪除日志 .addActionListener(this 。 setLayout(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 actionPerf
29、ormed(ActionEvent eif(e.getSource(= 保存日志 保存日志 (year,month,day 。else if(e.getSource(= 刪除日志 刪除日志 (year,month,day 。public void setYear(int yearthis.year=year 。public int getYear(return year 。public void setMonth(int monththis.month=month 。public int getMonth(return month 。public void setDay(int daythis
30、.day=day 。public int getDay(return day 。public void 設(shè)置信息條 (int year,int month,int day信息條.setText(+year+年+month+月+day+日。public void 設(shè)置文本區(qū) (String stext.setText(s 。public void 獲取日志內(nèi)容 (int year,int month,int dayString key=+year+month+day 。 tryFileInputStream inOne=new FileInputStream(file 。 ObjectInput
31、Stream inTwo=newObjectInputStream(inOne 。 table=(HashtableinTwo.readObject( 。 inOne.close( 。 inTwo.close( 。 catch(Exception ee if(table.containsKey(keyString m=+yea葉年+month+月+day+這一天有日志 記載 ,是否查看 ?。int ok=JOptionPane.showConfirmDialog(this,m, 詢問,JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE
32、 。 if(ok=JOptionPane.YES_OPTIONtext.setText(Stringtable.get(key 。 elsetext.setText( 。elsetext.setText( 無記錄 。public void 保存日志 (int year,int month,int dayString 日志內(nèi)容 =text.getText( 。String key=+year+month+day 。String m=+year+年+month+月+day+保存日志嗎?。 int ok=JOptionPane.showConfirmDialog(this,m, 詢問 ,JOptio
33、nPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE if(ok=JOptionPane.YES_OPTIONtryFileInputStream inOne=new FileInputStream(file 。ObjectInputStream inTwo=new ObjectInputStream(inOne 。table=(HashtableinTwo.readObject( 。 inOne.close( 。inTwo.close( 。 table.put(key, 日志內(nèi)容 。FileOutputStream out=newFileOutpu
34、tStream(file 。ObjectOutputStream objectOut=new ObjectOutputStream(out 。objectOut.writeObject(table 。 objectOut.close( 。out.close( 。catch(Exception eepublic void 刪除日志 (int year,int month,int dayString key=+year+month+day 。if(table.containsKey(keyString m=刪除+year+年+month+月+day+日的日志 嗎?。int ok=JOptionPane.showConfirmDialog(this,m, 詢問 ,JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE 。if(ok=JOptionPane.YES_OPT
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 幼兒教育學(xué) 幼兒教育概述課件
- 打造幼教服務(wù)產(chǎn)業(yè)鏈園區(qū)生態(tài)圈
- 2024-2025學(xué)年下學(xué)期高二生物人教版期末必刷常考題之生態(tài)系統(tǒng)的物質(zhì)循環(huán)
- 部編版二年級(jí)下冊(cè)第七單元《大象的耳朵》教案
- 8 4 拋物線-2026版53高考數(shù)學(xué)總復(fù)習(xí)A版精煉
- 2025屆河北省唐山市高三二模語文試題(解析版)
- 2024-2025學(xué)年四川省雅安市高三第一次診斷性考試語文試題(解析版)
- 2024-2025學(xué)年山東省威海市文登區(qū)高三第一次模擬語文試題(解析版)
- it項(xiàng)目應(yīng)急預(yù)案
- 信訪問題回復(fù)函
- 【高校環(huán)藝】室內(nèi)外手繪效果圖表現(xiàn)教案
- 《積極心理學(xué)(第3版)》 課件 第2章 心理流暢體驗(yàn)
- FURUNO 電子海圖 完整題庫(kù)
- DB50-T 548.4-2024城市道路交通管理設(shè)施設(shè)置規(guī)范第4部分:道路交通安全設(shè)施
- 項(xiàng)目股份買斷合同范本
- 上海市2023年高中學(xué)業(yè)水平考試生物試卷真題(含答案詳解)
- 校園文印店經(jīng)營(yíng)方案
- 2024屆重慶市沙坪壩區(qū)英語八年級(jí)第二學(xué)期期末監(jiān)測(cè)試題含答案
- 《幾種常見的天線》課件
- 【大廠案例】華為數(shù)據(jù)治理方法論與實(shí)踐解決方案
- DL-T5169-2013水工混凝土鋼筋施工規(guī)范
評(píng)論
0/150
提交評(píng)論