日历记事本-JAVA课程设计.

合集下载

Java日历记事本课程设计报告毕业用资料

Java日历记事本课程设计报告毕业用资料

Java日历记事本课程设计报告在设计日历记事本时,需要编写6个JAVA源文件:CalendarWindow.java、CalendarPad.java、NotePad.java、CalendarImage.java、Clock.java和CalendarMesssage.java效果图如下.CalendarWindow类import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.util.*;import java.io.*;public class CalendarWindow extends JFrame implements ActionListener,MouseListener,FocusListener{int year,month,day;CalendarMessage calendarMessage;CalendarPad calendarPad;NotePad notePad;JTextField showYear,showMonth;JTextField[]showDay;CalendarImage calendarImage;String picturename;Clock clock;JButton nextYear,previousYear,nextMonth,previousMonth;JButtonsaveDailyRecord,deleteDailyRecord,readDailyRecord;JButton getPicture;File dir;Color backColor=Color.white;public CalendarWindow(){dir=new File("./dailyRecord");dir.mkdir();showDay=new JTextField[42];for(int i=0;i<showDay.length;i++){showDay[i]=new JTextField();showDay[i].setBackground(backColor);showDay[i].setLayout(new GridLayout(3,3));showDay[i].addMouseListener(this);showDay[i].addFocusListener(this);}calendarMessage=new CalendarMessage();calendarPad=new CalendarPad();notePad=new NotePad();Calendar calendar=Calendar.getInstance();calendar.setTime(new Date());year=calendar.get(Calendar.YEAR);month=calendar.get(Calendar.MONTH)+1;day=calendar.get(Calendar.DAY_OF_MONTH);calendarMessage.setYear(year);calendarMessage.setMonth(month);calendarMessage.setDay(day);calendarPad.setCalendarMessage(calendarMessage);calendarPad.setShowDayTextField(showDay);notePad.setShowMessage(year,month,day);calendarPad.showMonthCalendar();doMark();calendarImage=new CalendarImage();calendarImage.setImageFile(new File("flower.jpg"));clock=new Clock();JSplitPane splitV1=new JSplitPane(JSplitPane.VERTICAL_SPLIT,calendarPad,calendarIm age);JSplitPane splitV2=new JSplitPane(JSplitPane.VERTICAL_SPLIT,notePad,clock);JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,splitV1,splitV2);add(splitH,BorderLayout.CENTER);showYear=new JTextField(""+year,6);showYear.setFont(newFont("TimesRoman",Font.BOLD,12));showYear.setHorizontalAlignment(JTextField.CENTER);showMonth=new JTextField(""+month,4);。

JAVA日历记事本课程设计报告

JAVA日历记事本课程设计报告

Java日历记事本课程设计报告在设计日历记事本时,需要编写6个JA V A源文件:CalendarWindow.java、CalendarPad.java、NotePad.java、CalendarImage.java、Clock.java和CalendarMesssage.java效果图如下. CalendarWindow类import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.util.*;import java.io.*;public class CalendarWindow extends JFrame implements ActionListener,MouseListener,FocusListener{int year,month,day;CalendarMessage calendarMessage;CalendarPad calendarPad;NotePad notePad;JTextField showYear,showMonth;JTextField[] showDay;CalendarImage calendarImage;String picturename;Clock clock;JButton nextYear,previousYear,nextMonth,previousMonth;JButton saveDailyRecord,deleteDailyRecord,readDailyRecord;JButton getPicture;File dir;Color backColor=Color.white ;public CalendarWindow(){dir=new File("./dailyRecord");dir.mkdir();showDay=new JTextField[42];for(int i=0;i<showDay.length;i++){showDay[i]=new JTextField();showDay[i].setBackground(backColor);showDay[i].setLayout(new GridLayout(3,3));showDay[i].addMouseListener(this);showDay[i].addFocusListener(this);}calendarMessage=new CalendarMessage();calendarPad=new CalendarPad();notePad=new NotePad();Calendar calendar=Calendar.getInstance();calendar.setTime(new Date());year=calendar.get(Calendar.YEAR);month=calendar.get(Calendar.MONTH)+1;day=calendar.get(Calendar.DAY_OF_MONTH);calendarMessage.setYear(year);calendarMessage.setMonth(month);calendarMessage.setDay(day);calendarPad.setCalendarMessage(calendarMessage);calendarPad.setShowDayTextField(showDay);notePad.setShowMessage(year,month,day);calendarPad.showMonthCalendar();doMark();calendarImage=new CalendarImage();calendarImage.setImageFile(new File("flower.jpg"));clock=new Clock();JSplitPane splitV1=new JSplitPane(JSplitPane.VERTICAL_SPLIT,calendarPad,calendarImage);JSplitPane splitV2=new JSplitPane(JSplitPane.VERTICAL_SPLIT,notePad,clock);JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,splitV1,splitV2);add(splitH,BorderLayout.CENTER);showYear=new JTextField(""+year,6);showYear.setFont(new Font("TimesRoman",Font.BOLD,12));showYear.setHorizontalAlignment(JTextField.CENTER);showMonth=new JTextField(""+month,4);showMonth.setFont(new Font("TimesRoman",Font.BOLD,12)); showMonth.setHorizontalAlignment(JTextField.CENTER); nextYear=new JButton("下年");previousYear=new JButton("上年");nextMonth=new JButton("下月");previousMonth=new JButton("上月");nextYear.addActionListener(this);previousYear.addActionListener(this);nextMonth.addActionListener(this);previousMonth.addActionListener(this);JPanel north=new JPanel();north.add(previousYear);north.add(showYear);north.add(nextYear);north.add(previousMonth);north.add(showMonth);north.add(nextMonth);add(north,BorderLayout.NORTH);saveDailyRecord=new JButton("保存日志"); deleteDailyRecord=new JButton("删除日志"); readDailyRecord=new JButton("读取日志"); saveDailyRecord.addActionListener(this); deleteDailyRecord.addActionListener(this); readDailyRecord.addActionListener(this);JPanel pSouth=new JPanel();pSouth.add(saveDailyRecord);pSouth.add(deleteDailyRecord);pSouth.add(readDailyRecord);add(pSouth,BorderLayout.SOUTH);getPicture=new JButton("选择日历图像");getPicture.addActionListener(this);pSouth.add(getPicture);add(pSouth,BorderLayout.SOUTH);setVisible(true);setBounds(60,60,660,480);validate();setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}public void actionPerformed(ActionEvent e){if(e.getSource()==nextYear){year++;showYear.setText(""+year);calendarMessage.setYear(year);calendarPad.setCalendarMessage(calendarMessage);calendarPad.showMonthCalendar();notePad.setShowMessage(year,month,day);doMark();}else if(e.getSource()==previousYear){year--;showYear.setText(""+year);calendarMessage.setYear(year);calendarPad.setCalendarMessage(calendarMessage);calendarPad.showMonthCalendar();notePad.setShowMessage(year,month,day);doMark();}else if(e.getSource()==nextMonth){month++;if(month<1) month=12;showMonth.setText(""+month);calendarMessage.setMonth(month);calendarPad.setCalendarMessage(calendarMessage);calendarPad.showMonthCalendar();notePad.setShowMessage(year,month,day);doMark();}else if(e.getSource()==previousMonth){month--;if(month<1) month=12;showMonth.setText(""+month);calendarMessage.setMonth(month);calendarPad.setCalendarMessage(calendarMessage);calendarPad.showMonthCalendar();notePad.setShowMessage(year,month,day);doMark();}else if(e.getSource()==showYear){String s=showYear.getText().trim();char a[]=s.toCharArray();boolean boo=false;for(int i=0;i<a.length;i++)if(!(Character.isDigit(a[i])))boo=true;if(boo==true)JOptionPane.showMessageDialog(this, "您输入了非法年份","警告",JOptionPane.WARNING_MESSAGE);else if(boo==false)year=Integer.parseInt(s);showYear.setText(""+year);calendarMessage.setYear(year);calendarPad.setCalendarMessage(calendarMessage);calendarPad.showMonthCalendar();notePad.setShowMessage(year,month,day);doMark();}else if(e.getSource()==saveDailyRecord){notePad.save(dir,year,month,day);doMark();}else if(e.getSource()==deleteDailyRecord){notePad.delete(dir,year,month,day);doMark();}else if(e.getSource()==readDailyRecord){notePad.read(dir,year,month,day);}else if (e.getSource() ==getPicture ) {FileDialog fd=new FileDialog(this,"打开文件对话框");fd.setVisible(true);String fileopen = null, filename = null;fileopen = fd.getDirectory();filename = fd.getFile();calendarImage.setImageFile(new File(fileopen,filename));}}public void mousePressed(MouseEvent e){JTextField text=(JTextField)e.getSource();String str=text.getText().trim();try{ day=Integer.parseInt(str);}catch(NumberFormatException exp){}calendarMessage.setDay(day);notePad.setShowMessage(year,month,day);}public void mouseReleased(MouseEvent e){}public void mouseEntered(MouseEvent e){}public void mouseExited(MouseEvent e){}public void mouseClicked(MouseEvent e){}public void focusGained(FocusEvent e){Component com=(Component)e.getSource();com.setBackground(Color.pink);}public void focusLost(FocusEvent e){Component com=(Component)e.getSource();com.setBackground(backColor);}public void doMark(){for(int i=0;i<showDay.length;i++){showDay[i].removeAll();String str=showDay[i].getText().trim();try{int n=Integer.parseInt(str);if(isHaveDailyRecord(n)==true){JLabel mess=new JLabel("有");mess.setFont(new Font("TimesRoman",Font.PLAIN,11));mess.setForeground(Color.blue);showDay[i].add(mess);}}catch(Exception exp){}}calendarPad.repaint();calendarPad.validate();}public boolean isHaveDailyRecord(int n){String key=""+year+""+month+""+n;String [] dayFile=dir.list();boolean boo=false;for(int k=0;k<dayFile.length;k++){if(dayFile[k].equals(key+".txt")){boo=true;break;}}return boo;}public String getPicture_address() {String address = null;try {InputStream outOne = new FileInputStream("picture_address.txt");ObjectInputStream outTwo = new ObjectInputStream(outOne);try {address = (String) outTwo.readObject();} catch (Exception ex) {}outTwo.close();} catch (IOException eee) {}if (address != null) {return address;} else {return "picture.jpg";}}public void actionPerformed1(ActionEvent e) {if (e.getActionCommand().equals("更改图片背景")) {FileDialog dia = new FileDialog(this, "选择图片", FileDialog.LOAD);dia.setModal(true);dia.setVisible(true);if ((dia.getDirectory() != null) && (dia.getFile() != null)) {try {FileOutputStream inOne = new FileOutputStream("picture_address.txt");ObjectOutputStream inTwo = new ObjectOutputStream(inOne);inTwo.writeObject(dia.getDirectory() + dia.getFile());inTwo.close();} catch (IOException ee) {}String picturename = getPicture_address();calendarImage.setImageFile(new File(picturename));}}public static void main(String args[]){new CalendarWindow();}}CalendarPad类import javax.swing.*;import java.awt .*;import java.awt.event.*;import java.util.*;import javax.swing.JPanel;public class CalendarPad extends JPanel{int year,month,day;CalendarMessage calendarMessage;JTextField[] showDay;JLabel title[];String[] 星期={"SUN 日","MON 一","TUE 二","WED 三","THU 四","FRI 四","SAT 六"};JPanel north,center;public CalendarPad(){setLayout(new BorderLayout());north=new JPanel();north.setLayout(new GridLayout(1,7));center=new JPanel();center.setLayout(new GridLayout(6,7));add(center ,BorderLayout.CENTER );add(north,BorderLayout.NORTH );title=new JLabel[7];for(int j=0;j<7;j++){title[j]=new JLabel();title[j].setFont(new Font("TimesRoman",Font.BOLD ,12));title[j].setText(星期[j]);title[j].setHorizontalAlignment(JLabel.CENTER);title[j].setBorder(BorderFactory.createRaisedBevelBorder());north.add(title[j]);}title[0].setForeground(Color.red);title[6].setForeground(Color.blue);}public void setShowDayTextField(JTextField[]text){showDay=text;for(int i=0;i<showDay.length;i++){showDay[i].setFont(new Font("TimesRoman",Font.BOLD ,15));showDay[i].setHorizontalAlignment(JTextField.CENTER);showDay[i].setEditable(false);center.add(showDay[i]);}}public void setCalendarMessage (CalendarMessage calendarMessage){ this.calendarMessage=calendarMessage;}public void showMonthCalendar(){String[] a=calendarMessage.getMonthCalendar();for(int i=0;i<42;i++)showDay[i].setText(a[i]);validate();}}CalendarMesssage类import java.util.Calendar;public class CalendarMessage {int year=-1,month=-1,day=-1;public int getYear(){return year;}public void setMonth(int month){if(month<=12&&month>=1)this.month=month;elsethis.month =1;}public int getMonth(){return month;}public void setDay(int day){this.day =day;}public int getDay(){return day ;}public String []getMonthCalendar(){String[] day=new String[42];Calendar rili =Calendar.getInstance();rili.set(year, month-1,1);int 星期几=rili.get(Calendar.DAY_OF_WEEK )-1;int dayAmount=0;if(month==1||month==3||month==5||month==7||month==8||month==10||month== 12)dayAmount=31;if(month==4||month==6||month==9||month==11)dayAmount=30;if(month==2)if(((year%4==0)&&(year%100!=0)||year%400==0))dayAmount=29;elsedayAmount=28;for(int i=0;i<星期几;i++)day[i]="";for(int i=星期几,n=1;i<星期几+dayAmount;i++){day[i]=String.valueOf(n);n++;}for(int i=星期几+dayAmount;i<42;i++)day[i]="";return day;}public void setYear(int year) {this.year = year;}}NotePad类import java.awt.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import java.io.*;import java.awt.event.*;public class NotePad extends JPanel implements ActionListener {JTextArea text;JTextField showMessage;JPopupMenu menu;JMenuItem itemCopy, itemCut, itemPaste, itemClear, btn;public NotePad() {showMessage = new JTextField();showMessage.setHorizontalAlignment(JTextField.CENTER);showMessage.setFont(new Font("TimesRoman", Font.BOLD, 16));showMessage.setForeground(Color.blue);showMessage.setBackground(Color.pink);showMessage.setBorder(BorderFactory.createRaisedBevelBorder());showMessage.setEditable(false);menu = new JPopupMenu();itemCopy = new JMenuItem("复制");itemCut = new JMenuItem("剪切");itemPaste = new JMenuItem("粘贴");itemClear = new JMenuItem("清空");btn = new JMenuItem("字体");itemCopy.addActionListener(this);itemCut.addActionListener(this);itemPaste.addActionListener(this);itemClear.addActionListener(this);btn.addActionListener(this);menu.add(itemCopy);menu.add(itemCut);menu.add(itemPaste);menu.add(itemClear);menu.add(btn);text = new JTextArea(10, 10);text.addMouseListener(new MouseAdapter() {public void mousePressed(MouseEvent e) {if (e.getModifiers() == InputEvent.BUTTON3_MASK)menu.show(text, e.getX(), e.getY());}});setLayout(new BorderLayout());add(showMessage, BorderLayout.NORTH);add(new JScrollPane(text), BorderLayout.CENTER);}public void setShowMessage(int year, int month, int day) {showMessage.setText("" + year + "年" + month + "月" + day + "日");showMessage.setForeground(Color.blue);showMessage.setFont(new Font("宋体", Font.BOLD, 15));}public void save(File dir, int year, int month, int day) {String dailyContent = text.getText();String fileName = "" + year + "" + month + "" + day + ".txt";String key = "" + year + "" + month + "" + day;String[] dayFile = dir.list();boolean boo = false;for (int k = 0; k < dayFile.length; k++) {if (dayFile[k].startsWith(key)) {boo = true;break;}}if (boo) {String m = "" + year + "年" + month + "月" + day+ "已有日志,将新的内容添加到日志吗?";int ok = JOptionPane.showConfirmDialog(this, m, "",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if (ok == JOptionPane.YES_OPTION) {try {File f = new File(dir, fileName);RandomAccessFile out = new RandomAccessFile(f, "rw");long fileEnd = out.length();byte[] bb = dailyContent.getBytes();out.seek(fileEnd);out.write(bb);out.close();} catch (IOException exp) {}}} else {String m = "" + year + "年" + month + "月" + day + "还没有日志,保存日志吗?";int ok = JOptionPane.showConfirmDialog(this, m, "询问",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if (ok == JOptionPane.YES_OPTION) {try {File f = new File(dir, fileName);RandomAccessFile out = new RandomAccessFile(f, "rw");long fileEnd = out.length();byte[] bb = dailyContent.getBytes();out.seek(fileEnd);out.write(bb);out.close();} catch (IOException exp) {}}}}public void delete(File dir, int year, int month, int day) {String key = "" + year + "" + month + "" + day;String[] dayFile = dir.list();boolean boo = false;for (int k = 0; k < dayFile.length; k++) {if (dayFile[k].startsWith(key)) {boo = true;break;}}if (boo) {String m = "删除" + year + "年" + month + "月" + day + "日的日志吗?";int ok = JOptionPane.showConfirmDialog(this, m, "询问",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if (ok == JOptionPane.YES_OPTION) {String fileName = "" + year + "" + month + "" + day + ".txt";File deleteFile = new File(dir, fileName);deleteFile.delete();}}else {String m = "" + year + "" + month + "" + day + "";JOptionPane.showMessageDialog(this, m, "提示",JOptionPane.WARNING_MESSAGE);}}public void read(File dir, int year, int month, int day) {String fileName = "" + year + "" + month + "" + day + ".txt";String key = "" + year + "" + month + "" + day;String[] dayFile = dir.list();boolean boo = false;for (int k = 0; k < dayFile.length; k++) {if (dayFile[k].startsWith(key)) {boo = true;break;}}if (boo) {String m = "" + year + "" + month + "" + day + "";int ok = JOptionPane.showConfirmDialog(this, m, "询问",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if (ok == JOptionPane.YES_OPTION) {text.setText(null);try {File f = new File(dir, fileName);FileReader inOne = new FileReader(f);BufferedReader inTwo = new BufferedReader(inOne);String s = null;while ((s = inTwo.readLine()) != null)text.append(s + "\n");inOne.close();inTwo.close();} catch (IOException exp) {}}} else {String m = "" + year + "" + month + "" + day + "";JOptionPane.showMessageDialog(this, m, "提示",JOptionPane.WARNING_MESSAGE);}}public void actionPerformed(ActionEvent e) {if (e.getSource() == itemCopy)text.copy();else if (e.getSource() == itemCut)text.cut();else if (e.getSource() == itemPaste)text.paste();else if (e.getSource() == itemClear)text.setText(null);if (e.getSource() == btn) {JFontDialog nFD = new JFontDialog("选择字体");nFD.setModal(true);nFD.setVisible(true);text.setFont(nFD.myFont);}}}class JFontDialog extends JDialog {private static final long serialVersionUID = 1L;JList fontpolics, fontstyle, fontsize;JTextField fontpolict, fontstylet, fontsizet;String example;JLabel FontResolvent;JButton buttonok, buttoncancel;Font myFont;public JFontDialog(String title) {Container container = getContentPane();container.setLayout(new BorderLayout());JPanel panel = new JPanel();panel.setLayout(new GridLayout(2, 1));JPanel FontSet, FontView;FontSet = new JPanel(new GridLayout(1, 4));FontView = new JPanel(new GridLayout(1, 2));example = "AaBbCcDdEe";FontResolvent = new JLabel(example, JLabel.CENTER);FontResolvent.setBackground(Color.WHITE);ListSelectionListener selectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) {if (((JList) e.getSource()).getName().equals("polic")) {fontpolict.setText((String) fontpolics.getSelectedValue());FontResolvent.setFont(new Font(fontpolict.getText(),FontResolvent.getFont().getStyle(), FontResolvent.getFont().getSize()));}if (((JList) e.getSource()).getName().equals("style")) {fontstylet.setText((String) fontstyle.getSelectedValue());FontResolvent.setFont(new Font(FontResolvent.getFont().getFontName(), fontstyle.getSelectedIndex(),FontResolvent.getFont().getSize()));}if (((JList) e.getSource()).getName().equals("size")) {fontsizet.setText((String) fontsize.getSelectedValue());try {Integer.parseInt(fontsizet.getText());} catch (Exception excepInt) {fontsizet.setText(FontResolvent.getFont().getSize()+ "");}FontResolvent.setFont(new Font(FontResolvent.getFont().getFontName(), FontResolvent.getFont().getStyle(),Integer.parseInt(fontsizet.getText())));}}};KeyListener keyListener = new KeyListener() {public void keyPressed(KeyEvent e) {if (e.getKeyCode() == 10) {if (((JTextField) e.getSource()).getName().equals("polic")) {FontResolvent.setFont(new Font(fontpolict.getText(),FontResolvent.getFont().getStyle(),FontResolvent.getFont().getSize()));}if (((JTextField) e.getSource()).getName().equals("style")) {fontstylet.setText((String) fontstyle.getSelectedValue());FontResolvent.setFont(new Font(FontResolvent.getFont().getFontName(), fontstyle.getSelectedIndex(),FontResolvent.getFont().getSize()));}if (((JTextField) e.getSource()).getName().equals("size")) {try {Integer.parseInt(fontsizet.getText());} catch (Exception excepInt) {fontsizet.setText(FontResolvent.getFont().getSize()+ "");}FontResolvent.setFont(new Font(FontResolvent.getFont().getFontName(), FontResolvent.getFont().getStyle(), Integer.parseInt(fontsizet.getText())));}}}public void keyReleased(KeyEvent e) {}public void keyTyped(KeyEvent e) {}};// 字体JPanel Fontpolic = new JPanel();Border border = BorderFactory.createLoweredBevelBorder();border = BorderFactory.createTitledBorder(border, "字体");Fontpolic.setBorder(border);Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();int taille = fonts.length;String[] policnames = new String[taille];for (int i = 0; i < taille; i++) {policnames[i] = fonts[i].getName();}fontpolics = new JList(policnames);fontpolics.setName("polic");fontpolics.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontpolics.addListSelectionListener(selectionListener);fontpolics.setVisibleRowCount(6);fontpolict = new JTextField(policnames[0]);fontpolict.setName("polic");fontpolict.addKeyListener(keyListener);JScrollPane jspfontpolic = new JScrollPane(fontpolics);Fontpolic.setLayout(new BoxLayout(Fontpolic, BoxLayout.PAGE_AXIS)); Fontpolic.add(fontpolict);Fontpolic.add(jspfontpolic);// 样式JPanel Fontstyle = new JPanel();border = BorderFactory.createLoweredBevelBorder();border = BorderFactory.createTitledBorder(border, "样式");Fontstyle.setBorder(border);String[] styles = { "PLAIN", "BOLD", "ITALIC", "BOLD ITALIC" };fontstyle = new JList(styles);fontstyle.setName("style");fontstyle.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontstyle.addListSelectionListener(selectionListener);fontstyle.setVisibleRowCount(6);fontstylet = new JTextField(styles[0]);fontstylet.setName("style");fontstylet.addKeyListener(keyListener);JScrollPane jspfontstyle = new JScrollPane(fontstyle);Fontstyle.setLayout(new BoxLayout(Fontstyle, BoxLayout.PAGE_AXIS)); Fontstyle.add(fontstylet);Fontstyle.add(jspfontstyle);// 大小JPanel Fontsize = new JPanel();border = BorderFactory.createLoweredBevelBorder();border = BorderFactory.createTitledBorder(border, "大小");Fontsize.setBorder(border);String[] sizes = { "10", "14", "18", "22", "26", "30" };fontsize = new JList(sizes);fontsize.setName("size");fontsize.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontsize.addListSelectionListener(selectionListener);fontsize.setVisibleRowCount(6);fontsizet = new JTextField(sizes[0]);fontsizet.setName("size");fontsizet.addKeyListener(keyListener);JScrollPane jspfontsize = new JScrollPane(fontsize);Fontsize.setLayout(new BoxLayout(Fontsize, BoxLayout.PAGE_AXIS)); Fontsize.add(fontsizet);Fontsize.add(jspfontsize);FontSet.add(Fontpolic);FontSet.add(Fontstyle);FontSet.add(Fontsize);FontView.add(FontResolvent);panel.add(FontSet);panel.add(FontView);JPanel panelnorth = new JPanel();panelnorth.setLayout(new FlowLayout());buttonok = new JButton("确定");buttoncancel = new JButton("取消");panelnorth.add(buttonok);panelnorth.add(buttoncancel);buttonok.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {myFont = FontResolvent.getFont();JFontDialog.this.setVisible(false);}});buttoncancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {JFontDialog.this.setVisible(false);}});container.add(panel, BorderLayout.CENTER);container.add(panelnorth, BorderLayout.SOUTH);setSize(400, 300);}}CalendarImage类import javax.swing.*;import java.io.*;import java.awt.*;public class CalendarImage extends JPanel{File imageFile;Image image;Toolkit tool;CalendarImage(){tool=getToolkit();}public void setImageFile(File f){imageFile=f;try{ image=tool.getImage(imageFile.toURI().toURL());}catch(Exception exp){}repaint();}public void paintComponent(Graphics g){super.paintComponent(g);int w=getBounds().width;int h=getBounds().height;g.drawImage(image, 0, 0, w, h, this);}}Clock类import java.applet.Applet;import java.applet.AudioClip;import java.awt.BasicStroke;import java.awt.Color;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.geom.Line2D;import java.io.File;import .MalformedURLException;import .URI;import .URL;import java.util.Date;import javax.swing.JPanel;public class Clock extends JPanel implements ActionListener { Date date;javax.swing.Timer secondTime;int hour,munite,second;Line2D secondLine,muniteLine,hourLine;Line2D m=new Line2D.Double(0,0,0,0);Line2D s=new Line2D.Double(0,0,0,0);int a,b,c,width,height;double pointSX[]=new double[60],pointSY[]=new double[60],pointMX[]=new double[60],pointMY[]=new double[60],pointHX[]=new double[60],pointHY[]=new double[60];Clock(){setBackground(Color.cyan);initPoint();secondTime=new javax.swing.Timer(1000,this);secondLine=new Line2D.Double(0,0,0,0);muniteLine=new Line2D.Double(0,0,0,0);hourLine=new Line2D.Double(0,0,0,0);secondTime.start();}private void initPoint(){width=getBounds().width;height=getBounds().height;pointSX[0]=0;pointSY[0]=-height/2*5/6;pointMX[0]=0;pointMY[0]=-(height/2*4/5);pointHX[0]=0;pointHY[0]=-(height/2*2/3);double angle=6*Math.PI/180;for(int i=0;i<59;i++){pointSX[i+1]=pointSX[i]*Math.cos(angle)-Math.sin(angle)*pointSY[i];pointSY[i+1]=pointSY[i]*Math.cos(angle)+pointSX[i]*Math.sin(angle);pointMX[i+1]=pointMX[i]*Math.cos(angle)-Math.sin(angle)*pointMY[i];pointMY[i+1]=pointMY[i]*Math.cos(angle)+pointMX[i]*Math.sin(angle);pointHX[i+1]=pointHX[i]*Math.cos(angle)-Math.sin(angle)*pointHY[i];pointHY[i+1]=pointHY[i]*Math.cos(angle)+pointHX[i]*Math.sin(angle);}for(int i=0;i<60;i++){pointSX[i]=pointSX[i]+width/2;pointSY[i]=pointSY[i]+height/2;pointMX[i]=pointMX[i]+width/2;pointMY[i]=pointMY[i]+height/2;pointHX[i]=pointHX[i]+width/2; pointHY[i]=pointHY[i]+height/2;}}public void paintComponent(Graphics g){super.paintComponent(g);initPoint();for(int i=0;i<60;i++){int m=(int)pointSX[i];int n=(int)pointSY[i];if(i%5==0){if(i==0||i==15||i==30||i==45){int k=10;g.setColor(Color.orange);g.fillOval(m-k/2, n-k/2, k, k);}else{int k=7;g.setColor(Color.orange );g.fillOval(m-k/2, n-k/2, k, k);}}else{int k=2;g.setColor(Color.black);g.fillOval(m-k/2, n-k/2, k, k);}}g.fillOval(width/2-5, height/2-5, 10, 10);Graphics2D g_2d=(Graphics2D)g;g_2d.setColor(Color.red);g_2d.draw(secondLine);BasicStroke bs=newBasicStroke(2f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_MITER);g_2d.setStroke(bs);g_2d.setColor(Color.blue);g_2d.draw(muniteLine);bs=newBasicStroke(2f,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER);g_2d.setStroke(bs);g_2d.setColor(Color.orange);g_2d.draw(hourLine);bs=newBasicStroke(4f,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER);g_2d.setStroke( bs);}public void actionPerformed(ActionEvent e){if(e.getSource()==secondTime){date=new Date();String s=date.toString();。

JAVA课程设计报告-日历记事本

JAVA课程设计报告-日历记事本

东华理工大学信息工程学院《JAVA技术应用开发》课程设计报告日历记事本******学号:************同组成员:无完成日期:2015.7.3目录1.项目概述 (2)2.需求分析 (2)3.概要设计 (3)3.1功能结构 (3)3.2布局 (3)4.详细设计及功能实现 (4)4.1结构 (4)4.2主界面 (5)4.3日历模块 (8)4.4记事本模块 (9)4.5记事列表模块 (12)4.6提醒功能 (13)5.运行测试 (15)6.总结 (19)1.项目概述日历记事本是将日历和记事本结合在一起,用户可以任意选择某一天,保存这一天需要记录的记事,或者任意查看某一天已经记录的记事。

同时还应具备提醒功能,当到达提醒时间时会自动弹出提醒。

2.需求分析日历记事本大致分为日历和记事两个部分。

①日历部分首先,需要选择日期,用户可以通过点击按钮选择前一年或后一年,同样也可以选择前一个月或后一个月,当月份为1月时,用户点击前一个月,会自动跳转到前一年的12月,同理,在12月时点击后一个月,会自动跳转到下一年的1月。

另外,当选择跨度比较大时,需要多次点击按钮,很不方便,所以需要一个下拉框,可以直接选择某一年或某一个月。

当用户改变选择日期时,日历会自动显示出这一个月的日历,并且可以通过点击某一天,来进行添加记事的操作,鼠标经过日历或点击日历时,会有不同的效果以提示用户这是可以点击的。

②记事部分首先,需要一个文本域给用户编辑记事内容,记事和日历部分所选择的日期是相关的,当用户点击日历选择某一天,则记事本上端会显示出选择的日期信息。

同时,记事应该还具有设置提醒的功能,用户点击设置提醒按钮后,会弹出一个新的对话框,用来选择提醒时间。

为保存记事,应将记事以文件的形式存储在计算机上。

另外,当用户想查看所有记事,或者想搜索某一则记事时,可以将日历部分换成一个表格,列出所有的记事,或者符合搜索结果的记事。

3.概要设计3.1功能结构日历记事本以功能划分,大致分为日历、记事列表及记事本三个部分:3.2布局软件界面的大致布局如下图,可以通过点击按钮将日历切换为记事列表4.详细设计及功能实现4.1结构①类结构②文件存储结构程序第一次运行时,会在设定的位置自动创建路径:“.../日历记事本/data/”。

记事本java课程设计

记事本java课程设计

记事本java课程设计一、课程目标知识目标:1. 掌握Java编程语言基础,包括数据类型、运算符、控制流程等;2. 学会使用记事本作为Java程序开发工具,并了解其基本操作;3. 理解面向对象编程思想,掌握类的定义、方法和属性的使用;4. 能够运用所学知识设计简单的记事本应用程序。

技能目标:1. 培养学生运用Java语言编写程序的能力;2. 培养学生运用记事本进行程序代码编写、保存和运行的操作能力;3. 培养学生分析问题、设计解决方案并实现的能力;4. 提高学生的团队协作和沟通能力,通过小组讨论和分享,优化程序设计。

情感态度价值观目标:1. 培养学生对编程的兴趣和热情,激发学习动力;2. 培养学生的耐心和毅力,面对编程中的困难和挑战,保持积极态度;3. 培养学生的创新意识,鼓励尝试不同的编程思路和方法;4. 培养学生的分享精神,乐于与同伴交流学习心得和经验。

课程性质:本课程为实践性较强的学科,注重培养学生的编程实践能力和实际应用能力。

学生特点:学生处于初中年级,具有一定的逻辑思维能力和计算机操作基础,对新鲜事物充满好奇。

教学要求:教师应关注学生的个体差异,因材施教,注重理论与实践相结合,提高学生的编程兴趣和实际操作能力。

在教学过程中,将课程目标分解为具体的学习成果,以便于教学设计和评估。

二、教学内容1. Java基础知识回顾:- 数据类型与变量- 运算符与表达式- 控制流程(分支、循环)2. 记事本应用程序设计:- 记事本的基本功能需求分析- 类的定义与使用- 方法和属性的编写与调用- 面向对象编程思想的应用3. 教学大纲:- 第一章:Java基础回顾(2课时)- 1.1 数据类型与变量- 1.2 运算符与表达式- 1.3 控制流程(分支、循环)- 第二章:记事本应用程序设计(3课时)- 2.1 记事本功能需求分析- 2.2 类的定义与使用- 2.3 方法和属性的编写与调用- 2.4 面向对象编程思想的应用4. 教学进度安排:- Java基础回顾:2周- 记事本应用程序设计:3周- 课程总结与项目展示:1周5. 教材章节关联:- 《Java编程基础》第1章至第3章- 《Java面向对象编程》第1章至第3章教学内容的选择和组织确保了科学性和系统性,以教材为依据,结合课程目标,旨在帮助学生掌握Java编程基础,并能运用所学知识设计出实用的记事本应用程序。

java课程设计策画日历记事本

java课程设计策画日历记事本

课程设计说明书课程: Java程序设计院系:计算机科学学院专业班级:计算机科学与技术(2)班组员:张少华、张天阳2010年6月 26 日《Java程序设计》课程设计——日历记事本我们开发了一个实现有日历标记的记事本软件,日历记事本面板由日历和和记事本两部分组成。

日历部分可以调节年份,月份,日期,星期。

记事本可以实行查看,保存,删除等操作,并且每一步操作都有相应提示。

本软件是一个实用性很强,简洁,方便的功能软件。

引言Java是一种纯面向对象的、网络编程首选的语言。

Java技术作为软件开的一种革命性技术,已被列为当今世界信息技术的主流之一。

为了适应时代潮流,我们应该加强对Java的学习,更好的掌握这门课程。

为此,我们成了一个课程小组,经过小组成的商讨之后,我们决定以“日历记事本”为设题材,借此巩固加深我们对Java 的了解。

本次课程设计的实例虽然比较简单,程序设计也不是很复杂,但在此程序的设计过程也是一个学习过程,更是对复杂程序的一个学习过程,还能培养我们的数抽象能力。

因此,我们觉得这次课程设计是非常有意义的,能为我们今后学习面向过程的程序设计作一些铺垫。

1、设计的目的与要求;(1)为用户提供一个简便的日历记事本;(2)对java技术的进一步了解和简单的运用;(3)初步的接触软件工程;2.设计目的与任务本课程设计所要求达到的目的和任务:通过Java程序设计的一些重要理论基础来实现“日历记事本”的“日历”和“记事本”的双重功能。

并通过此次课程设计的训练,使学生巩固和加深对Java这门课程的理解,通过利用所学到的计算科学的理论知识,提高解决实际问题的能力,增强运算、编程和使用技术资料的技能,通过实际问题的分析设计、编程和调试,掌握应用软件的分析方法和工程设计方法,能正确阐述设计和实验结果。

通过这次课程设计,培养实事求是、认真、严谨的科学态度和刻苦钻研不断创新的精神,逐步建立正确的全局观念。

3.设计方案3.1 总体设计(1)问题定义:创建日历记事本,实现对某日期的事情进行记录等功能。

Java日历记事本课程设计报告

Java日历记事本课程设计报告

Java日历记事本课程设计报告在设计日历记事本时,需要编写6个JAVA源文件:、、、、和效果图如下. CalendarWindow类import .*;import .*;import .*;import .*;public class CalendarWindow extends JFrame implements ActionListener,MouseListener,FocusListener{int year,month,day;CalendarMessage calendarMessage;CalendarPad calendarPad;NotePad notePad;JTextField showYear,showMonth;JTextField[] showDay;CalendarImage calendarImage;String picturename;Clock clock;JButton nextYear,previousYear,nextMonth,previousMonth;JButton saveDailyRecord,deleteDailyRecord,readDailyRecord;JButton getPicture;File dir;Color backColor= ;public CalendarWindow(){dir=new File("./dailyRecord");();showDay=new JTextField[42];for(int i=0;i<;i++){showDay[i]=new JTextField();showDay[i].setBackground(backColor);showDay[i].setLayout(new GridLayout(3,3));showDay[i].addMouseListener(this);showDay[i].addFocusListener(this);}calendarMessage=new CalendarMessage();calendarPad=new CalendarPad();notePad=new NotePad();Calendar calendar=();(new Date());year=;month=+1;day=;(year);(month);(day);(calendarMessage);(showDay);(year,month,day);();doMark();calendarImage=new CalendarImage();(new File(""));clock=new Clock();JSplitPane splitV1=new JSplitPane,calendarPad,calendarImage);JSplitPane splitV2=new JSplitPane,notePad,clock);JSplitPane splitH=new JSplitPane,splitV1,splitV2);add(splitH,;showYear=new JTextField(""+year,6);(new Font("TimesRoman",,12));;showMonth=new JTextField(""+month,4);(new Font("TimesRoman",,12));;nextYear=new JButton("下年");previousYear=new JButton("上年");nextMonth=new JButton("下月");previousMonth=new JButton("上月");(this);(this);(this);(this);JPanel north=new JPanel();(previousYear);(showYear);(nextYear);(previousMonth);(showMonth);(nextMonth);add(north,;saveDailyRecord=new JButton("保存日志");deleteDailyRecord=new JButton("删除日志");readDailyRecord=new JButton("读取日志");(this);(this);(this);JPanel pSouth=new JPanel();(saveDailyRecord);(deleteDailyRecord);(readDailyRecord);add(pSouth,;getPicture=new JButton("选择日历图像");(this);(getPicture);add(pSouth,;setVisible(true);setBounds(60,60,660,480);validate();setDefaultCloseOperation;}public void actionPerformed(ActionEvent e){ if()==nextYear){year++;(""+year);(year);(calendarMessage);();(year,month,day);doMark();}else if()==previousYear){year--;(""+year);(year);(calendarMessage);();(year,month,day);doMark();}else if()==nextMonth){month++;if(month<1) month=12;(""+month);(month);(calendarMessage);();(year,month,day);doMark();}else if()==previousMonth){month--;if(month<1) month=12;(""+month);(month);(calendarMessage);();(year,month,day);doMark();}else if()==showYear){String s=().trim();char a[]=();boolean boo=false;for(int i=0;i<;i++)if(!(a[i])))boo=true;if(boo==true)(this, "您输入了非法年份","警告",;else if(boo==false)year=(s);(""+year);(year);(calendarMessage);();(year,month,day);doMark();}else if()==saveDailyRecord){(dir,year,month,day);doMark();}else if()==deleteDailyRecord){(dir,year,month,day);doMark();}else if()==readDailyRecord){(dir,year,month,day);}else if () ==getPicture ) {FileDialog fd=new FileDialog(this,"打开文件对话框");(true);String fileopen = null, filename = null;fileopen = ();filename = ();(new File(fileopen,filename));}}public void mousePressed(MouseEvent e){JTextField text=(JTextField)();String str=().trim();try{ day=(str);}catch(NumberFormatException exp){}(day);(year,month,day);}public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){}public void mouseExited(MouseEvent e){}public void mouseClicked(MouseEvent e){}public void focusGained(FocusEvent e){Component com=(Component)();;}public void focusLost(FocusEvent e){Component com=(Component)();(backColor);}public void doMark(){for(int i=0;i<;i++){showDay[i].removeAll();String str=showDay[i].getText().trim();try{int n=(str);if(isHaveDailyRecord(n)==true){JLabel mess=new JLabel("有");(new Font("TimesRoman",,11));;showDay[i].add(mess);}}catch(Exception exp){}}();();}public boolean isHaveDailyRecord(int n){ String key=""+year+""+month+""+n;String [] dayFile=();boolean boo=false;for(int k=0;k<;k++){if(dayFile[k].equals(key+".txt")){boo=true;break;}}return boo;}public String getPicture_address() {String address = null;try {InputStream outOne = new FileInputStream("");ObjectInputStream outTwo = new ObjectInputStream(outOne);try {address = (String) ();} catch (Exception ex) {}();} catch (IOException eee) {}if (address != null) {return address;} else {return "";}}public void actionPerformed1(ActionEvent e) {if ().equals("更改图片背景")) {FileDialog dia = new FileDialog(this, "选择图片", ;(true);(true);if (() != null) && () != null)) {try {FileOutputStream inOne = new FileOutputStream("");ObjectOutputStream inTwo = new ObjectOutputStream(inOne);() + ());();} catch (IOException ee) {}String picturename = getPicture_address();(new File(picturename));}}}public static void main(String args[]){new CalendarWindow();}}CalendarPad类import .*;import .*;import .*;import class CalendarPad extends JPanel{int year,month,day;CalendarMessage calendarMessage;JTextField[] showDay;JLabel title[];String[] 星期={"SUN 日","MON 一","TUE 二","WED 三","THU 四","FRI 四","SAT 六"};JPanel north,center;public CalendarPad(){setLayout(new BorderLayout());north=new JPanel();(new GridLayout(1,7));center=new JPanel();(new GridLayout(6,7));add(center , );add(north, );title=new JLabel[7];for(int j=0;j<7;j++){title[j]=new JLabel();title[j].setFont(new Font("TimesRoman", ,12));title[j].setText(星期[j]);title[j].setHorizontalAlignment;title[j].setBorder());(title[j]);}title[0].setForeground;title[6].setForeground;}public void setShowDayTextField(JTextField[]text){showDay=text;for(int i=0;i<;i++){showDay[i].setFont(new Font("TimesRoman", ,15));showDay[i].setHorizontalAlignment;showDay[i].setEditable(false);(showDay[i]);}}public void setCalendarMessage (CalendarMessage calendarMessage){=calendarMessage;}public void showMonthCalendar(){String[] a=();for(int i=0;i<42;i++)showDay[i].setText(a[i]);validate();}}CalendarMesssage类import class CalendarMessage {int year=-1,month=-1,day=-1;public int getYear(){return year;}public void setMonth(int month){if(month<=12&&month>=1)=month;else=1;}public int getMonth(){return month;}public void setDay(int day){=day;}public int getDay(){return day ;}public String []getMonthCalendar(){String[] day=new String[42];Calendar rili =();(year, month-1,1);int 星期几= )-1;int dayAmount=0;if(month==1||month==3||month==5||month==7||month==8||month==10 ||month==12)dayAmount=31;if(month==4||month==6||month==9||month==11)dayAmount=30;if(month==2)if(((year%4==0)&&(year%100!=0)||year%400==0))dayAmount=29;elsedayAmount=28;for(int i=0;i<星期几;i++)day[i]="";for(int i=星期几,n=1;i<星期几+dayAmount;i++){day[i]=(n);n++;}for(int i=星期几+dayAmount;i<42;i++)day[i]="";return day;}public void setYear(int year) {= year;}}NotePad类import .*;import .*;import .*;import class NotePad extends JPanel implements ActionListener { JTextArea text;JTextField showMessage;JPopupMenu menu;JMenuItem itemCopy, itemCut, itemPaste, itemClear, btn;public NotePad() {showMessage = new JTextField();;(new Font("TimesRoman", , 16));;;());(false);menu = new JPopupMenu();itemCopy = new JMenuItem("复制");itemCut = new JMenuItem("剪切");itemPaste = new JMenuItem("粘贴");itemClear = new JMenuItem("清空");btn = new JMenuItem("字体");(this);(this);(this);(this);(this);(itemCopy);(itemCut);(itemPaste);(itemClear);(btn);text = new JTextArea(10, 10);(new MouseAdapter() {public void mousePressed(MouseEvent e) {if () ==(text, (), ());}});setLayout(new BorderLayout());add(showMessage, ;add(new JScrollPane(text), ;}public void setShowMessage(int year, int month, int day) { ("" + year + "年" + month + "月" + day + "日");;(new Font("宋体", , 15));}public void save(File dir, int year, int month, int day) {String dailyContent = ();String fileName = "" + year + "" + month + "" + day + ".txt";String key = "" + year + "" + month + "" + day;String[] dayFile = ();boolean boo = false;for (int k = 0; k < ; k++) {if (dayFile[k].startsWith(key)) {boo = true;break;}}if (boo) {String m = "" + year + "年" + month + "月" + day+ "已有日志,将新的内容添加到日志吗";int ok = (this, m, "",, ;if (ok == {try {File f = new File(dir, fileName);RandomAccessFile out = new RandomAccessFile(f, "rw");long fileEnd = ();byte[] bb = ();(fileEnd);(bb);();} catch (IOException exp) {}}} else {String m = "" + year + "年" + month + "月" + day + "还没有日志,保存日志吗";int ok = (this, m, "询问",, ;if (ok == {try {File f = new File(dir, fileName);RandomAccessFile out = new RandomAccessFile(f, "rw");long fileEnd = ();byte[] bb = ();(fileEnd);(bb);();} catch (IOException exp) {}}}}public void delete(File dir, int year, int month, int day) { String key = "" + year + "" + month + "" + day;String[] dayFile = ();boolean boo = false;for (int k = 0; k < ; k++) {if (dayFile[k].startsWith(key)) {boo = true;break;}}if (boo) {String m = "删除" + year + "年" + month + "月" + day + "日的日志吗";int ok = (this, m, "询问",, ;if (ok == {String fileName = "" + year + "" + month + "" + day + ".txt";File deleteFile = new File(dir, fileName);();}}else {String m = "" + year + "" + month + "" + day + "";(this, m, "提示",;}}public void read(File dir, int year, int month, int day) { String fileName = "" + year + "" + month + "" + day + ".txt";String key = "" + year + "" + month + "" + day;String[] dayFile = ();boolean boo = false;for (int k = 0; k < ; k++) {if (dayFile[k].startsWith(key)) {boo = true;break;}}if (boo) {String m = "" + year + "" + month + "" + day + "";int ok = (this, m, "询问",, ;if (ok == {(null);try {File f = new File(dir, fileName);FileReader inOne = new FileReader(f);BufferedReader inTwo = new BufferedReader(inOne);String s = null;while ((s = ()) != null)(s + "\n");();();} catch (IOException exp) {}}} else {String m = "" + year + "" + month + "" + day + "";(this, m, "提示",;}}public void actionPerformed(ActionEvent e) {if () == itemCopy)();else if () == itemCut)();else if () == itemPaste)();else if () == itemClear)(null);if () == btn) {JFontDialog nFD = new JFontDialog("选择字体");(true);(true);;}}}class JFontDialog extends JDialog {private static final long serialVersionUID = 1L;JList fontpolics, fontstyle, fontsize;JTextField fontpolict, fontstylet, fontsizet;String example;JLabel FontResolvent;JButton buttonok, buttoncancel;Font myFont;public JFontDialog(String title) {Container container = getContentPane();(new BorderLayout());JPanel panel = new JPanel();(new GridLayout(2, 1));JPanel FontSet, FontView;FontSet = new JPanel(new GridLayout(1, 4));FontView = new JPanel(new GridLayout(1, 2));example = "AaBbCcDdEe";FontResolvent = new JLabel(example, ;;ListSelectionListener selectionListener = new ListSelectionListener() {public void valueChanged(ListSelectionEvent e) {if (((JList) ()).getName().equals("polic")) {((String) ());(new Font(),().getStyle(), FontResolvent.getFont().getSize()));}if (((JList) ()).getName().equals("style")) {((String) ());(new Font().getFontName(), (),().getSize()));}if (((JList) ()).getName().equals("size")) {((String) ());try {());} catch (Exception excepInt) {().getSize()+ "");}(new Font().getFontName(), ().getStyle(),())));}}};KeyListener keyListener = new KeyListener() {public void keyPressed(KeyEvent e) {if () == 10) {if (((JTextField) ()).getName().equals("polic")) {(new Font(),().getStyle(),().getSize()));}if (((JTextField) ()).getName().equals("style")) {((String) fontstyle.getSelectedValue());(new Font().getFontName(), (),().getSize()));}if (((JTextField) ()).getName().equals("size")) {try {());} catch (Exception excepInt) {().getSize()+ "");}(new Font().getFontName(), ().getStyle(), (fontsizet.getText())));}}}public void keyReleased(KeyEvent e) {}public void keyTyped(KeyEvent e) {}};etLocalGraphicsEnvironment().getAllFonts();int taille = ;String[] policnames = new String[taille];for (int i = 0; i < taille; i++) {policnames[i] = fonts[i].getName();}fontpolics = new JList(policnames);("polic");;(selectionListener);(6);fontpolict = new JTextField(policnames[0]);("polic");(keyListener);JScrollPane jspfontpolic = new JScrollPane(fontpolics);(new BoxLayout(Fontpolic, );(fontpolict);(jspfontpolic);;import .*;import .*;public class CalendarImage extends JPanel{File imageFile;Image image;Toolkit tool;CalendarImage(){tool=getToolkit();}public void setImageFile(File f){imageFile=f;try{ image=().toURL());}catch(Exception exp){}repaint();}public void paintComponent(Graphics g){(g);int w=getBounds().width;int h=getBounds().height;(image, 0, 0, w, h, this);}}Clock类import class Clock extends JPanel implements ActionListener {Date date;secondTime;int hour,munite,second;Line2D secondLine,muniteLine,hourLine;Line2D m=new (0,0,0,0);Line2D s=new (0,0,0,0);int a,b,c,width,height;double pointSX[]=new double[60],pointSY[]=new double[60],pointMX[]=new double[60],pointMY[]=new double[60],pointHX[]=new double[60],pointHY[]=new double[60];Clock(){setBackground;initPoint();secondTime=new secondLine=new (0,0,0,0);muniteLine=new (0,0,0,0);hourLine=new (0,0,0,0);();}private void initPoint(){width=getBounds().width;height=getBounds().height;pointSX[0]=0;pointSY[0]=-height/2*5/6;pointMX[0]=0;pointMY[0]=-(height/2*4/5);pointHX[0]=0;pointHY[0]=-(height/2*2/3);double angle=6*180;for(int i=0;i<59;i++){pointSX[i+1]=pointSX[i]*(angle)(angle)*pointSY[i];pointSY[i+1]=pointSY[i]*(angle)+pointSX[i]*(angle);pointMX[i+1]=pointMX[i]*(angle)(angle)*pointMY[i];pointMY[i+1]=pointMY[i]*(angle)+pointMX[i]*(angle);pointHX[i+1]=pointHX[i]*(angle)(angle)*pointHY[i];pointHY[i+1]=pointHY[i]*(angle)+pointHX[i]*(angle);}for(int i=0;i<60;i++){pointSX[i]=pointSX[i]+width/2;pointSY[i]=pointSY[i]+height/2;pointMX[i]=pointMX[i]+width/2;pointMY[i]=pointMY[i]+height/2;pointHX[i]=pointHX[i]+width/2; pointHY[i]=pointHY[i]+height/2;}}public void paintComponent(Graphics g){(g);initPoint();for(int i=0;i<60;i++){int m=(int)pointSX[i];int n=(int)pointSY[i];if(i%5==0){if(i==0||i==15||i==30||i==45){int k=10;;(m-k/2, n-k/2, k, k);}else{int k=7;);(m-k/2, n-k/2, k, k);}}else{int k=2;;(m-k/2, n-k/2, k, k);}}(width/2-5, height/2-5, 10, 10);Graphics2D g_2d=(Graphics2D)g;;(secondLine);BasicStroke bs=new BasicStroke(2f,,;(bs);;(muniteLine);bs=new BasicStroke(2f,,;(bs);;(hourLine);bs=new BasicStroke(4f,,;(bs);}public void actionPerformed(ActionEvent e){if()==secondTime){date=new Date();String s=();hour=(11, 13));munite=(14, 16));second=(17, 19));int h=hour%12;a=second;b=munite;c=h*5+munite/12;(width/2,height/2,(int)pointSX[a],(int)pointSY[a]);(width/2,height/2,(int)pointMX[b],(int)pointMY[b]);(width/2,height/2,(int)pointHX[c],(int)pointHY[c]);repaint();if ((munite==0)&&(second==0)){try{File f=new File("");URI uri=();URL url=();AudioClip aau;aau=(url);();}catch(MalformedURLException ex){();}}}}}21。

java课程设计记事本设计报告

java课程设计记事本设计报告

java课程设计记事本设计报告一、教学目标本课程旨在通过Java编程语言实现一个记事本应用程序,让学生掌握Java编程的基本概念和方法,培养学生的编程能力和解决问题的能力。

1.理解Java编程语言的基本语法和结构。

2.掌握Java编程中的数据类型、变量、运算符、控制语句等基本概念。

3.学习Java中的类和对象的概念,理解封装、继承和多态的原理。

4.熟悉Java中的常用类库和方法。

5.能够运用Java编程语言编写简单的程序。

6.能够使用Java编程语言实现一个记事本应用程序,包括文本的增删改查等功能。

7.能够分析并解决编程过程中遇到的问题。

情感态度价值观目标:1.培养学生的团队合作意识和沟通能力,通过小组合作完成项目。

2.培养学生的创新思维和解决问题的能力,鼓励学生进行自主学习和探索。

3.培养学生的学习兴趣和自信心,让学生感受到编程的乐趣和成就感。

二、教学内容本课程的教学内容主要包括Java编程语言的基本概念和方法,以及记事本应用程序的设计和实现。

1.Java编程语言的基本概念和方法:–数据类型、变量、运算符、控制语句等基本概念。

–类和对象的概念,封装、继承和多态的原理。

–常用类库和方法的使用。

2.记事本应用程序的设计和实现:–用户界面设计:创建文本框、按钮等控件,实现用户输入和显示功能。

–文件操作:实现文件的打开、保存、关闭等功能,使用文件读写技术。

–文本处理:实现文本的增删改查等功能,使用数据结构和算法进行文本管理。

三、教学方法本课程将采用多种教学方法,包括讲授法、讨论法、案例分析法和实验法等,以激发学生的学习兴趣和主动性。

1.讲授法:教师通过讲解Java编程语言的基本概念和方法,以及记事本应用程序的设计和实现,引导学生掌握相关知识。

2.讨论法:学生分组进行讨论,分享自己的理解和思路,互相学习和交流。

3.案例分析法:分析实际案例,让学生了解记事本应用程序的实际应用场景和设计思路。

4.实验法:学生通过编写代码和进行实验,实现记事本应用程序的功能,培养学生的实际编程能力和解决问题的能力。

《Java》课程设计》记事本

《Java》课程设计》记事本

《Java课程设计》记事本课程设计报告书目录一、设计课题二、设计目的三、操作环境四、设计场所(机房号、机器号或自己机器)五、设计过程(设计内容及主要程序模块)六、本次设计中用到的课程知识点(列出主要知识点)七、设计过程中遇到的问题及解决办法八、程序清单五、设计过程(设计内容及主要模块,不少于3000字)1.设计要求1)界面设计2)功能实现(1)文件菜单:新建、打开、保存、另存为、退出等。

(2)其中新建菜单项可以新建一个记事本程序;打开菜单项可以打开一个用户指定的文本文件,并将其内容显示在记事本的文本区域;保存和另存为菜单项可分别实现文件的保存和另存为3)编辑菜单:复制、剪切和粘贴等4)帮助菜单:软件版本信5)右键弹出快捷菜单2.总体设计1)功能模块图:图一功能模块图2)功能描述1、打开记事本。

首先是标准型的记事本,拥有文件、编辑。

格式和帮助。

如图1所示:图1标准型记事本界面2、在标准型的记事本界面中,进行的新建一个本件名字叫新记事本。

如图2记事本文件帮助新建打开保存另存为退出复制剪切粘贴编辑关于记事本右键快捷格式字体颜色图2新建记事本功能3、用打开文件打开刚刚新建的新记事本。

如图三所示。

图3—打开文件4、点击退出即可退出,如图4所示:图4—退出记事本5、点击帮助可以看到有关记事本的相关信息,其中有作者名、版本、许可条款、隐私声明等必要信息。

如图5所示:图5—帮助相关信息6、右键可实现复制、粘贴、剪切、清除等常用功能,方便用户可以快捷方便的使用记事本。

如图6所示:图6—右键功能7、编辑也可实现制、粘贴、剪切、清除等常用功能,方便用户选择自己适合的方式,自由选择方便的快捷方式使用。

如图7:图7—编辑八、程序清单package test;import java.io.File;import java.io.*;import java.awt.event.*;import java.awt.Toolkit;import java.awt.*;import javax.swing.*;import javax.swing.filechooser.*;public class Notebook extends JFrame implements ActionListener,ItemListener{ //组件创建JButton b_save,b_close; //按钮JTextArea textArea; //文本框File tempFile; //文件JPanel jp; //面板JMenu file,edit,style,help; //菜单JMenuItemf_new,f_open,f_save,f_close,f_saveas,e_copy, e_paste,e_cut,e_clear,e_selectAll,e_find,e_rep lace,s_font,s_color,h_editor,h_help; //菜单条JMenuBar jmb;JScrollPane jsp; //滚动面板JPopupMenu popUpMenu = new JPopupMenu(); //右键弹出式菜单JLabel stateBar;//标签JLabel jl,jj;JFileChooser jfc = new JFileChooser(); //文件选择JMenuItemje_copy,je_paste,je_cut,je_clear,je_selectAll,je _find,je_replace; //弹出式菜单条public Notebook(){jfc.addChoosableFileFilter(new FileNameExtensionFilter("文本文件(*.txt)","txt"));jmb = new JMenuBar();textArea = new JTextArea();jsp = new JScrollPane(textArea);file = new JMenu("文件");edit = new JMenu("编辑");style = new JMenu("格式");help = new JMenu("帮助");je_copy = new JMenuItem("复制(C) ");je_paste = new JMenuItem("粘贴(P) ");je_cut = new JMenuItem("剪切(X) ");je_clear = new JMenuItem("清除(D) ");je_selectAll = new JMenuItem("全选(A) ");je_find = new JMenuItem("查找(F) ");je_replace = new JMenuItem("替换(R) ");je_copy.addActionListener(this); //给弹窗式的各组件添加监听器je_paste.addActionListener(this);je_cut.addActionListener(this);je_clear.addActionListener(this);je_selectAll.addActionListener(this);je_find.addActionListener(this);je_replace.addActionListener(this);//给界面上方的菜单条添加监听器f_new = new JMenuItem("新建(N)");f_new.setAccelerator(KeyStroke.getKeyS troke('N',InputEvent.CTRL_MASK,false)); //设置带修饰符快捷键f_new.addActionListener(this);f_open = new JMenuItem("打开(O)");f_open.setAccelerator(KeyStroke.getKey Stroke('O',InputEvent.CTRL_MASK,false));f_open.addActionListener(this);f_save = new JMenuItem("保存(S)");f_save.setAccelerator(KeyStroke.getKey Stroke('S',InputEvent.CTRL_MASK,false));f_save.addActionListener(this);f_saveas = new JMenuItem("另存为");f_saveas.setAccelerator(KeyStroke.getKe yStroke(KeyEvent.VK_S,InputEvent.CTRL_ MASK|InputEvent.SHIFT_MASK));f_saveas.addActionListener(this);f_close = new JMenuItem("退出(W)");f_close.setAccelerator(KeyStroke.getKey Stroke('W',InputEvent.CTRL_MASK,false));f_close.addActionListener(this);e_copy = new JMenuItem("复制(C)");e_copy.setAccelerator(KeyStroke.getKey Stroke('C',InputEvent.CTRL_MASK,false));e_copy.addActionListener(this);e_paste = new JMenuItem("粘贴(V)");e_paste.setAccelerator(KeyStroke.getKeyStro ke('V',InputEvent.CTRL_MASK,false));e_paste.addActionListener(this);e_cut = new JMenuItem("剪切(X)"); e_cut.setAccelerator(KeyStroke.getKeyStroke ('X',InputEvent.CTRL_MASK,false));e_cut.addActionListener(this);e_clear = new JMenuItem("清除(D)");e_clear.setAccelerator(KeyStroke.getKeyStrok e('D',InputEvent.CTRL_MASK,false));e_clear.addActionListener(this);e_selectAll = new JMenuItem("全选(A)");e_selectAll.setAccelerator(KeyStroke.getKey Stroke('A',InputEvent.CTRL_MASK,false));e_selectAll.addActionListener(this);e_find = new JMenuItem("查找(F)");e_find.setAccelerator(KeyStroke.getKeyStrok e('F',InputEvent.CTRL_MASK,false));e_copy.addActionListener(this);e_replace = new JMenuItem("替换(R)");e_replace.setAccelerator(KeyStroke.getK eyStroke('R',InputEvent.CTRL_MASK,false)) ;e_replace.addActionListener(this);s_font = new JMenuItem("字体(T)");s_font.setAccelerator(KeyStroke.getKeyStrok e('T',InputEvent.CTRL_MASK,false));s_font.addActionListener(this);s_color = new JMenuItem("颜色(C)...");s_color.setAccelerator(KeyStroke.getKeyStro ke(KeyEvent.VK_C,InputEvent.CTRL_MAS K | InputEvent.SHIFT_MASK));s_color.addActionListener(this);h_editor = new JMenuItem("关于记事本");h_editor.setAccelerator(KeyStroke.getKeyStro ke(KeyEvent.VK_E,InputEvent.CTRL_MAS K));h_editor.addActionListener(this);h_help = new JMenuItem("帮助信息(H)");h_help.setAccelerator(KeyStroke.getKeyStrok e(KeyEvent.VK_I,InputEvent.CTRL_MASK) );h_help.addActionListener(this);//添加右键弹出式菜单popUpMenu.add(je_copy);popUpMenu.add(je_paste);popUpMenu.add(je_cut);popUpMenu.add(je_clear);popUpMenu.addSeparator();popUpMenu.add(je_selectAll);popUpMenu.add(je_find);popUpMenu.add(je_replace);//编辑区鼠标事件,点击右键弹出"编辑"菜单textArea.addMouseListener(new MouseAdapter(){public void mouseReleased(MouseEvent e) {if(e.getButton() == MouseEvent.BUTTON3)popUpMenu.show(e.getComponent(), e.getX(), e.getY());} //e.getComponent()和textArea具有同等效果public void mouseClicked(MouseEvent e){if(e.getButton() == MouseEvent.BUTTON1)popUpMenu.setVisible(false);}});this.setJMenuBar(jmb);this.setTitle("记事本程序");file.add(f_new); //添加文件菜单组件file.add(f_open);file.addSeparator(); //加分隔线file.add(f_save);file.add(f_saveas);file.addSeparator();file.add(f_close);edit.add(e_copy); //添加编辑菜单组件edit.add(e_paste);edit.add(e_cut);edit.add(e_clear);edit.addSeparator();edit.add(e_selectAll);edit.add(e_find);edit.add(e_replace);style.addSeparator();style.add(s_font);style.add(s_color);jmb.add(file); //添加格式菜单组件jmb.add(edit);jmb.add(style);jmb.add(help);help.add(h_editor); //添加帮助菜单组件help.add(h_help);//textArea.setWrapStyleWord(true); //设置在单词过长的时候是否要把长单词移到下一行。

日历记事本课程设计报告

日历记事本课程设计报告

Java程序设计课程设计报告XXX日历记事本专业XXX学生XXX班级XXX学号XXX指导教师XXX完成日期XXX目录1概述 (1)1.1 课程设计目的 (1)1.2 课程设计容 (1)2 系统需求分析 (1)2.1 系统目标 (1)2.2 主体功能 (1)2.3开发环境 (1)3系统概要设计 (2)3.1 系统的功能模块划分与系统流程图 (2)4 系统详细设计 (2)5 测试 (4)5.1 测试方案 (4)5.2 测试结果 (4)6 小结 (6)参考文献 (7)附录 (8)附录1 源程序清单 (8)日历记事本1 概述1.1 课程设计目的1) 巩固和提高java编程技术。

2)培养掌握成学设计的基本思路和方法。

3)加强研发、调试程序的能力。

4)增强分析、解决问题的能力。

5)提高科技论文写作能力。

1.2 课程设计容设计GUI界面的日历记事本。

系统将日历、记事本功能结合在一起,用户可以方便地在任何日期记录下有关容或查看某个日期的记录容。

2 系统需求分析2.1 系统目标1.系统界面的左侧是日历。

该日历可以按年份前后翻动,鼠标单击“上年”按钮时,当前日历的年份减一;当鼠标左键单击“下年”按钮,当前日历的年份加一。

2.该日历也可以在某年按月前后翻动。

当鼠标左键单击“上月”按钮时,当前日历的月份减一;当鼠标左键单击“下月”按钮时,当前日历的月份加一。

3.使用鼠标左键单击选定的日期,如已有记录容,系统将弹出对话框提示该日已有记录容,并询问用户是否用记事本显示该容。

4.用户选择具体日期后,可以将记事本的当前容保存起来,形成日志。

2.2 主体功能用户可以方便地在任何日期记录下有关容或查看某个日期的记录容。

通过按按钮“上年”和“下年”对年份进行翻页。

通过按按钮“上月”和“下月”对月份进行翻页。

用户可以通过输入年份来查看自己的日志。

2.3 开发环境Windows XP;jdk1.5.0-0-05;ultraedit开发工具3 系统概要设计3.1 系统的功能模块划分与系统流程图本日历记事本共有4个java源文件。

java课程设计日历记事本

java课程设计日历记事本

java课程设计日历记事本湖南人文科技学院计算机系2009年6月19日- 1 -::1;(1)为用户提供一个简便的日历记事本;(2)对java技术的进一步了解和简单的运用;(3)初步的接触软件工程;26月8日分析课题、分配任务;对题目进行初步分析 6月9日建立模型,完成整体设计以及功能模块分析 6月10日确立每个类的功能,完成对算法的分析 6月11日完成CalendarPad类的设计6月12日完成对Year类的设计6月13日完成对Month类的设计6月14日完成对NotePad类的设计6月15日紧系程序测试与修改6月16日完成设计,整理说明书6月19日打包发布程序设计成绩:(教师填写)指导老师:(签字)2009年月日- 2 -摘要 ..................................................................... ................................................................... - 4 - 1. 引言 ..................................................................... ...................................................................... - 5 - 2.设计目的与任务 ..................................................................... ................................................... - 5 - 3.设计方案...................................................................... ............................................................... - 6 -3.1 总体设计 ..................................................................... ................................................... - 6 -3.2设计要求 ..................................................................... .................................................... - 6 -3.3系统的主要功能...................................................................... ....................................... - 6 -3.4系统功能结构图...................................................................... ....................................... - 6 -3.5运行功能(截图) ................................................................... ..................................... - 7 -4.结束语 ..................................................................... .................................................................... - 9 - 5.致谢 ..................................................................... .................................................................... - 9 - 6.参考文献...................................................................... ............................................................. - 10 - 7.附录A:源程序 ..................................................................... .................................................... - 11 - 8附录B:编码规范 ..................................................................... ............................................. - 24 -- 3 -本课程设计通过代码实现将理论知识和具体实践相结合,巩固提高了对JAVA的相关方法与概念的理解,使学生的发散思维及动手能力进一步加强,加强对计算机及软件工程的进一步了解。

日历表java课程设计

日历表java课程设计

日历表java课程设计一、教学目标本课程旨在通过Java编程语言实现一个简单的日历表应用程序,帮助学生掌握基本的编程概念和技能,培养他们的逻辑思维能力和问题解决能力。

具体的教学目标如下:1.了解Java编程语言的基本语法和结构。

2.掌握面向对象编程的基本概念,如类、对象、封装、继承和多态。

3.学习日历表的基本结构和功能,包括年、月、日和星期等信息。

4.能够使用Java编程语言编写简单的程序。

5.学会使用Java编程语言实现日历表的基本功能,如显示当前日期、切换月份等。

6.掌握使用Java编程语言处理日期和时间的常用方法。

情感态度价值观目标:1.培养学生的团队合作意识和沟通能力,通过小组合作完成日历表项目。

2.培养学生的创新思维和问题解决能力,鼓励他们提出新的想法和改进方案。

3.培养学生的学习兴趣和自信心,让他们感受到编程的乐趣和成就感。

二、教学内容本课程的教学内容主要包括Java编程语言的基本概念和语法、面向对象编程的原理和方法、日历表的基本结构和功能。

具体的教学大纲如下:1.Java编程语言的基本概念和语法:–数据类型、变量和常量–运算符和表达式–控制语句(条件语句、循环语句)–函数和方法2.面向对象编程的原理和方法:–类和对象的概念–属性和方法的封装–继承和多态的原理和应用3.日历表的基本结构和功能:–年、月、日和星期的表示方法–日历表的布局和设计–日历表的功能实现(显示当前日期、切换月份等)三、教学方法为了提高学生的学习兴趣和主动性,本课程将采用多种教学方法相结合的方式进行教学。

具体的教学方法如下:1.讲授法:教师通过讲解Java编程语言的基本概念和语法、面向对象编程的原理和方法,为学生提供系统的知识结构。

2.案例分析法:教师通过分析具体的日历表案例,引导学生理解和掌握日历表的设计和实现方法。

3.实验法:学生通过编写Java程序实现日历表的功能,培养他们的实际编程能力和问题解决能力。

4.小组讨论法:学生分组合作完成日历表项目,通过讨论和交流促进团队合作和沟通能力的发展。

java日历课程设计详细设计

java日历课程设计详细设计

java日历课程设计详细设计一、教学目标本课程旨在通过Java编程语言实现一个简单的日历功能,让学生掌握Java基本语法、面向对象编程思想以及常用数据结构。

同时,培养学生的编程兴趣,提高解决实际问题的能力。

1.掌握Java基本语法和关键字。

2.理解面向对象编程的基本概念,如类、对象、封装、继承和多态。

3.熟悉常用数据结构,如数组、链表、栈和队列。

4.能够运用Java语法和面向对象编程思想编写简单的程序。

5.能够运用常用数据结构解决实际问题。

6.学会使用Java开发工具和调试技巧。

情感态度价值观目标:1.培养学生的编程兴趣,提高自主学习能力。

2.培养学生团队合作精神,学会与他人分享和交流。

3.培养学生解决问题的能力,培养创新思维。

二、教学内容本课程的教学内容主要包括Java基本语法、面向对象编程思想和常用数据结构。

具体安排如下:1.Java基本语法:介绍Java编程语言的基本语法,包括数据类型、运算符、控制语句等。

2.面向对象编程:讲解面向对象编程的基本概念,如类、对象、封装、继承和多态。

通过实例让学生理解并掌握这些概念。

3.常用数据结构:介绍数组、链表、栈和队列等常用数据结构,并通过实例让学生学会运用这些数据结构解决实际问题。

4.日历实现:利用所学知识,让学生动手实现一个简单的日历功能,巩固所学知识,提高解决实际问题的能力。

三、教学方法本课程采用讲授法、案例分析法和实验法等多种教学方法,以激发学生的学习兴趣和主动性。

1.讲授法:通过讲解Java基本语法、面向对象编程思想和常用数据结构,让学生掌握理论知识。

2.案例分析法:通过分析实际案例,让学生学会运用所学知识解决实际问题。

3.实验法:让学生动手实践,实现日历功能,提高学生的实际编程能力。

四、教学资源1.教材:选用权威、实用的Java编程教材,为学生提供理论知识的学习材料。

2.参考书:提供相关领域的参考书籍,丰富学生的知识体系。

3.多媒体资料:制作精美的PPT,直观展示知识点,帮助学生更好地理解。

日历记事本-JAVA课程设计

日历记事本-JAVA课程设计

该类创建动态日历记事本的主窗口,该类含有main方法,是程序的入口程序,CalenderWindow类的成员变量中有5种重要类型的对象,CalendarPad、NotePad、Calendarlmage、Clock、CalendarMessage 对象。

2.2.2Cale nderMessage.java该类用来刻画和“日期”有关的数据。

2.2.3Cale nderPad.java该类是JPanel类的子类,所创建的对象是CalendarWindow类的重要成员之一,用来表示”日历”,即负责显示和修改Cale ndarMessage对象中的日期数据。

2.2.4Notepad.java该类是JPanel的一个子类,创建的对象表示“记事本”,提供编辑读取和保存阐述日志的功能。

2.2.5Cale ndarlmage.java该类所创建的对象是CalendarWindow类的成员之一,负责绘制图像。

2.2.6Clock.java该类创建的对象是CalendarWindow类的成员之一,负责显示时钟。

日历记事本用到的一些重要的类以及之间的关系如图1所示。

图1类之间的组合关系图 2.3功能模块此设计共有以下几个功能模块。

2.3.1年份改变选择日期保存并标记有”显示日志删除并去掉有图2流程图2.5类、方法、属性说明2.5.1CalendarWindow 类(1)成员变量•year,mo nth和day是int型数据,它们的值分别确定年份、月份和日期。

-calendarMessage是CalendarMessage对象,该对象可以处理和日期有关的数据。

-calendarPad是CalendarPad对象,该对象可以显示和日期有关的数据。

-notePad是NotePad对象,具有编辑、读取、保存和删除日志的功能。

-showYear和showMonth是JTextField 类创建的文本框,用来显示年份和月份。

-showDay数组的每个单元是JTextField类创建的用来显示日期的文本框。

重庆科技学院java程序课程设计汇本日历记事本

重庆科技学院java程序课程设计汇本日历记事本

Java程序设计课程设计报告目录目录 (2)1 概述 (1)1.1 课程设计目的 (1)1.2 课程设计容 (1)2 系统需求分析 (1)2.1 系统目标 (1)2.2 主体功能 (1)2.3 开发环境 (2)3系统概要设计 (2)3.1 系统的功能模块划分与系统流程图 (2)4系统详细设计 (3)5 测试 (5)5.1 测试方案 (5)5.2 测试结果 (5)6 小结 (8)参考文献 (10)附录 (11)附录1 源程序清单 (11)学生成绩管理系统的设计1 概述1.1 课程设计目的1)巩固和提高java编程技术。

2)培养掌握成学设计的基本思路和方法。

3)加强研发、调试程序的能力。

4)增强分析、解决问题的能力。

5)提高科技论文写作能力。

1.2 课程设计容设计GUI界面的日历记事本。

系统将日历、记事本功能结合在一起,用户可以方便地在任何日期记录下有关容或查看某个日期的记录容。

2 系统需求分析2.1 系统目标1. 系统界面的左侧是日历。

该日历可以按年份前后翻动,鼠标单击“上年”按钮时,当前的日历的年份减一;当鼠标左键单击“下年”按钮,当前日历年份加一。

2. 该日历也可以在某年按月前后翻动,鼠标单击“上月”按钮时,当前的日历的月份减一;当鼠标左键单击“下月”按钮,当前日历月份加一。

3. 使用鼠标左键单击选定的日期,如已有记录容,系统将弹出对话框提示该日已有记录容,并询问用户是否用记事本显示该容。

2.2 主体功能用户可以方便地在任何日期记录下有关容或查看某个日期的记录容。

通过按按钮“上年”和“下年”对年份进行翻页。

通过按按钮“上月”和“下月”对月份进行翻页。

用户可以通过输入年份来查看自己的日志。

2.3 开发环境Windows XP;jdk1.5.0-0-05;ultraedit开发工具3系统概要设计3.1 系统的功能模块划分与系统流程图本日历记事本Array共有4个java源文件。

CalendarPad.java该java文件生成的类负责创建本日历记事本程序主窗口。

java桌面课程设计记事本

java桌面课程设计记事本

java桌面课程设计记事本一、教学目标本课程的目标是让学生掌握Java语言实现桌面应用程序的基本技能,通过学习Java语言基础和GUI编程,培养学生的编程能力和解决实际问题的能力。

在知识目标方面,要求学生掌握Java语言基本语法、面向对象编程思想、常用类库和GUI组件的使用。

在技能目标方面,要求学生能够独立设计并实现一个桌面记事本应用程序,掌握Java编程的基本流程。

在情感态度价值观目标方面,培养学生的团队合作意识,提高学生解决问题的能力,使学生认识到计算机编程在实际应用中的重要性。

二、教学内容本课程的教学内容主要包括Java语言基础、面向对象编程、GUI编程和桌面应用程序设计。

具体包括以下几个部分:1.Java语言基础:Java语言的基本语法、数据类型、运算符、控制结构、数组、字符串等。

2.面向对象编程:类与对象、封装、继承、多态、接口、集合等。

3.GUI编程:Swing组件、事件处理、布局管理、菜单栏、工具栏等。

4.桌面应用程序设计:记事本应用程序的需求分析、设计、实现和测试。

三、教学方法为了提高学生的学习兴趣和主动性,本课程将采用多种教学方法相结合的方式。

包括:1.讲授法:讲解Java语言基础、面向对象编程和GUI编程的基本概念和原理。

2.案例分析法:分析典型的桌面应用程序案例,引导学生学会分析问题和解决问题。

3.实验法:让学生动手编写代码,实现桌面记事本应用程序,提高学生的实际操作能力。

4.讨论法:学生进行小组讨论,分享学习心得和经验,培养学生的团队合作意识。

四、教学资源为了支持教学内容和教学方法的实施,丰富学生的学习体验,我们将准备以下教学资源:1.教材:《Java核心技术卷I》、《Java GUI编程》等。

2.参考书:《Java编程思想》、《Effective Java》等。

3.多媒体资料:教学PPT、视频教程、在线代码示例等。

4.实验设备:计算机、网络环境、编程软件(如Eclipse、IntelliJ IDEA等)。

日历记事本-JAVA课程设计..

日历记事本-JAVA课程设计..

沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学图7 删除后页面图4.设计体会经过几天的努力,参考了一些书和网上的资料,完成了一个日历记事本的设计。

由于只学过一学期的Java课程,知识掌握的有限,所以此程序不是特别复杂。

在这个过程中,在把书本上的知识给系统的复习了一下的同时,同时也发现了自己的太多不足,对JA V A语言整体知识构架不够熟悉,不能灵活地运用所学的知识点。

自己的编程方式也不是太标准,经常出现代码写错而调试很久的低级错误情况出现。

通过这次课程设计,我明白了编写程序,不仅要求对课本知识有较深刻的了解,同时要求程序设计者有较强的思维和动手能力。

还要熟悉常用的编程技巧和编程思想,不能只关心程序的运行结果,更要注重程序代码的结构,编程者更要有严谨地态度。

本次课程设计不仅巩固了以前所学的知识,还有通过设计过程中大量地查阅网络文章,对一些关键知识点逐个地了解并解决相关问题。

所以网络这个强大的工具,确实是我们学习之中可以借助的一个很好的帮手。

网络是我们学习的最好的老师之一。

有问题,问网络,是一个很好的习惯。

因此学到了不少书本上没有的知识;学到了很多java编程知识。

可以说它给了我一次自我评估的机会。

通过设计让我知道了那些方面我还是有欠缺的,促使我花时间弥补。

总之,本次课程设计收获颇丰。

5.参考文献沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学沈阳大学。

记事本java课程设计

记事本java课程设计

记事本java课程设计一、课程目标知识目标:1. 理解Java语言的基本语法和程序结构;2. 掌握使用记事本进行Java编程的方法;3. 学习面向对象编程思想,了解类和对象的基本概念;4. 掌握基本的输入输出操作,文件读写方法。

技能目标:1. 能够使用记事本编写简单的Java程序;2. 能够运用面向对象编程思想设计简单的类和对象;3. 能够实现基本的用户交互功能,如输入输出操作;4. 能够对程序进行调试和修改,解决常见错误。

情感态度价值观目标:1. 培养学生对编程的兴趣和热情,激发创新思维;2. 培养学生良好的编程习惯,注重代码规范;3. 培养学生团队协作能力,学会与他人共同解决问题;4. 培养学生面对困难的勇气和毅力,勇于尝试和改进。

课程性质:本课程为实践性较强的Java编程入门课程,通过记事本进行编程实践,使学生在动手操作中掌握Java语言的基本知识。

学生特点:学生处于初级阶段,对编程有一定兴趣,但缺乏实际操作经验,需要通过具体实例和实际操作来提高。

教学要求:教师需关注学生个体差异,提供个性化指导,确保学生在实践中掌握Java编程基本技能,并注重培养学生的情感态度价值观。

教学过程中,将目标分解为具体学习成果,便于教学设计和评估。

二、教学内容1. Java语言基础:- 数据类型、变量、常量- 运算符、表达式、语句- 控制结构:顺序结构、分支结构、循环结构- 数组、字符串2. 面向对象编程:- 类的定义、属性、方法- 对象的创建、使用- 封装、继承、多态3. 常用类和接口:- Scanner类实现用户输入- File类和IOException处理文件操作- String类和StringBuffer类操作字符串4. 基本输入输出:- System.out.println()输出- Scanner类实现键盘输入5. 简单的记事本程序设计:- 实现文本文件的读取和保存- 添加菜单和功能选项- 支持基本的文本编辑功能(如撤销、剪切、复制、粘贴)教学内容根据课程目标,结合课本章节进行组织,确保学生能循序渐进地掌握Java编程知识。

电子日历记事本--Java课程设计

电子日历记事本--Java课程设计

《面向对象程序设计》课程设计报告题目:电子日历记事本的设计院(系):信息科学与工程学院专业班级:计算机科学与技术1201班学生姓名:程伟学号: 20121183011指导教师:吴奕20 14 年 12 月 29 日至20 15 年 1 月 9 日华中科技大学武昌分校制面向对象程序设计课程设计任务书目录1需求与总体设计 11.1需求分析 11.2总体设计思路 11.2.1功能图 11.2.2类图 22详细设计 (3)2.1 CalendarPad类说明 32.2 Year类说明 32.3 Month 类模块 42.4 NotePad类说明 43编码实现 63.1 CalendarPad模块 63.2 Year模块 113.3 Month 模块 143.4 NotePad模块 164系统运行与测试 234.1程序主界面 234.2日志查看——无日志 234.3建立日志 244.4日志查看——有日志 244.5删除日志 26总结 271需求与总体设计1.1需求分析根据题目要求,将日历与记事本功能相结合,实现对某日期的事件进行记录的功能,设计出简洁方便美观的GUI界面。

将本程序主界面可以分为四个部分:日历日期信息展示、年份、月份、记事本内容、记事本下方的时钟,用四个类来实现其“日历”和“记事本”这两大功能。

通过主类CalendarPad创建动日历记事本软件的主界面,且该类中含有main方法,程序从该类开始执行。

再用余下的year、mouth、NotePad类来显示并改变日期和实现记事本的功能。

1.2总体设计思路1. 可以编辑日历的日期2. 可以判断当前日期是否存在日志记录3. 对有日志记录的日期,可以对该日期的日志记录进行修改和删除4. 对没有日志记录的日期,可以创建并保存新建的日志记录5. 对保存的日志加密,查看时得输入密码1.2.1功能图1.2.2类图2详细设计2.1 CalendarPad类说明该模块设计主要主要包含以下成员变量:年(year)月(month)日(day)存放日期的表(Hashtable)存放日志的文件(File)主要方法有:创建程序主面板的构造方法(CalendarPad)处理ActionEvent事件的接口方法(actionPerformed)程序开始运行的main()方法。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
2.2.2 CalenderMessage.java
该类用来刻画和“日期”有关的数据。
2.2.3 CalenderPad.java
该类是JPanel类的子类,所创建的对象是CalendarWindow类的重要成员之一,用来表示”日历”,即负责显示和修改CalendarMessage对象中的日期数据。
2.1.2系统界面的右侧是记事本和一个时钟。用鼠标单击日历上的日期,就可以通过该记事本编辑有关日志,并将日志保存到一个文件。该文件的名字是由当前日期组成的字符序列。用户可以查看、删除某个日期的日志,也可以继续向某个日志添加新的内容。2.1.3当某个日期有日志时,显示该日期的外观上就会出现“有”标记,表明这个日期有日志;当用户删除某个日期的日志后,该日期的外观上的“有”
日历记事本用到的一些重要的类以及之间的关系如图1所示。
图1类之间的组合关系图
2.3功能模块
此设计共有以下几个功能模块。
2.3.1年份改变
点击一次“上年”按钮可增加一年,点击一次“下年”按钮可减少一年,多次连
续点击即可依次改变多个年份。
2.3.2月份改变
点击一次“上月”按钮可以增加一月,点击一次“下年”按钮可以减少一月,多
·nextYear等是JButton创建的按钮对象,名字依次为“下年”、“上年”、“下月”、“上
月”。这些按钮都将当前窗口注册为自己的ActionEvent事件监听者。
·saveDauktRecord,deleteDailyRecord,readDailyRecord是JButton创建的按钮对象,
·year,month和day是int型数据,它们的值分别确定年份、月份和日期。
·calendarMessage是CalendarMessage对象,该对象可以处理和日期有关的数据。
·calendarPad是CalendarPad对象,该对象可以显示和日期有关的数据。
·notePad是NotePad对象,具有编辑、读取、保存和删除日志的功能。
分显示出来。
2.3.6时钟显示
以传统时钟(有时针、分针、秒针)的模式显示当前的时间。
2.3.7保存、删除、读取日志。
可以在没有记载日志的日期里记载日志并保存,可以对以保存的日志进行读取、修改或者删除。
2.4流程图如下
图2流程图
2.5类、方法、属性说明
2.5.1CalendarWindow类
(1)成员变量
日历记事本
1.课程设计目的
通过此次课程设计,巩固所学Java语言基本知识,增进Java语言编辑基本功,掌握JDK、Editplus、Eclipse、JCreator等开发工具的运用,拓宽常用类库的应用。使我们通过该教学环节与手段,把所学课程及相关知识加以融会贯通,全面掌握Java语言的编程思想及面向对象程序设计的方法,为今后从事实际工作打下坚实的基础。
名字依次为“保存日志”、“删除日志”、“读取日志”。这些按钮都当前窗口注册为自
己的ActionEvent事件监听者。
(2)方法
·CalendarWindow()是构造方法,负责完成窗口的初始化。
·actionPerformed(AcrionEvent)方法是CalendarWindow类实现的ActionListner接
口中的方法。
·mousePressed(MouseEvent)方法是CalendarWindow类实现的MouseListener接口中
的方法。
2.2.1 CalendarWindow.java主类
该类创建动态日历记事本的主窗口,该类含有main方法,是程பைடு நூலகம்的入口
程序,CalenderWindow类的成员变量中有5种重要类型的对象,CalendarPad、NotePad、CalendarImage、Clock、CalendarMessage对象。
标记就会消失。
2.2设计方法
在设计日历记事本时,需要编写6个Java源文件:CalendarWindow.java、CalendarPad.java、NotePad.java、CalendarImage.java、Clock.java和CalendarMessage.java。
日历记事本除了需要编写的上述6个Java源文件所给出的类外,还需要Java系统提供的一些重要的类,如JTextField、JTextArea和File类。
2.2.4 Notepad.java
该类是JPanel的一个子类,创建的对象表示“记事本”,提供编辑读取和保存阐述日志的功能。
2.2.5 CalendarImage.java
该类所创建的对象是CalendarWindow类的成员之一,负责绘制图像。
2.2.6 Clock.java
该类创建的对象是CalendarWindow类的成员之一,负责显示时钟。
本课程设计设计GUI界面的日历记事本,系统将日历和记事本结合在一起,可以方便的保存、查看日志,即在任何日期记载下有关内容或查看某个日期记载的内容。
2.设计方案论证
2.1设计思路
2.1.1本系统界面的左侧是日历和一幅图像。该日历可以按年前后翻动,用鼠标左键单击“上年”按钮,可将当前日历的年份减一;用鼠标左键单击“下年”按钮,可将当前日历的年份加一。该日历还可以在某年内按月前后翻动,用鼠标单击“上月”按钮,可将当前日历的月份减一;用鼠标单击“下月”按钮,可将当前日历的月份增一。
·showYear和showMonth是JTextField类创建的文本框,用来显示年份和月份。
·showDay数组的每个单元是JTextField类创建的用来显示日期的文本框。
·calendarImage是CalendarImage创建的对象,用来显示图像。
·clock是Clock创建的对象,用来显示时钟。
次连续点击即可一次改变多个月份。
2.3.3日期显示
用于显示当前所选择的所在的年份月份的所有日期、星期,并在记载有日志的日期格中左上角显示“有”标记,而没有记载日志的日期则没有任何标记。
2.3.4图片显示
为了使本设计界面美观,设置了图片显示模块,使整个设计更加实用、美观、大方。
2.3.5日志显示
界面的右侧上半部的文本框中,可以选择某天记载日志,并且读取的日志在此部
相关文档
最新文档