Perpetual calendar based on Java (course design)

Java-based perpetual calendar

Resource link: Java-based perpetual calendar (course design)


Summary

Since its birth more than ten years ago, the Java programming language has been successfully used in various fields such as network computing and mobile. For developers, it has many advantages such as simplicity, object-oriented, robustness, security, structure neutrality, portability and high performance. This time we use JAVA to design a perpetual calendar program. The program runs in the form of a web page and supports a graphical interface. It can display the date and week in the form of a calendar. The user can input the date by himself, supports searching the date, and can update the date. It is a simple and easy-to-use small application.

Keywords : JAVA, graphical interface, perpetual calendar

1 Introduction

The predecessor of Java was Oak, which was only applied to consumer electronics products at first. Later its developers discovered that it can also be used on a wider range of Internet. In 1995, the name of the Java language changed from 0ak to Java. In 1997, J2SE1.1 was released. In 1998, J2SE1.2 was released, marking the birth of Java2. For more than ten years, the Java programming language and platform have been successfully used in various fields such as network computing and mobile. The architecture of Java consists of Java language, Java class, Java API, and Java virtual machine. It has many advantages such as simplicity, object-oriented, robustness, safety, structure neutrality, portability and high performance. Java supports multi-thread programming, and the Java runtime system has a mature solution for multi-thread synchronization. Java platform standards are Java ME, Java SE and Java EE. Java has developed to this day, and its outstanding achievements and status in the industry are beyond doubt. Among the many development tools that support Java, the main ones are 7JavaDevelopment Kit, NetBeans, Jcreator, JBuilder, JDeveloper and Eclipse. Among them, Java Development Kit, referred to as JDK, is the basis of most development tools. Each of the above development tools has advantages and disadvantages. For developers, it is important to choose a suitable development tool according to their own development scale, development content, software and hardware environment and other factors.

2 Demand Analysis

For dates, there are 31 days in January, March, May, July, August, October, and December; 30 days in April, June, September, and November; 29 days in February in leap years, and 28 days in normal years. There is a leap year every 4 years, a leap year every 100 years, and a leap year every 400 years. According to the above conditions, given any year and month, the number of days in the current month can be calculated.

For time, divide the dial into 12 equal parts, each corresponding to one hour; divide the dial into 60 equal parts, each corresponding to one minute; divide the dial into 3600 equal parts, each corresponding to one second.

The angle turned by the minute hand per second: minute_angle=(minute+second/60)*360/60;

The angle turned by the hour hand per second: hour_angle=(hour-12+minute/60)*360/12;

According to the above conditions, you can calculate the specific position of the hour, minute and second hand on the dial at any time, and use the Graphics2D class to draw on the panel.

Associate the label with the date so that the specific information of the date can be displayed, such as holidays, daily fortune, auspicious days, etc.

By calling the system time, make a timing device, and realize the alarm clock function by combining windows and labels.

You can change the interface style by setting the background and background picture of the clock, calendar, label, etc., so as to realize the skinning function.

Combine menus, panels, labels, and buttons to create a simple and practical visual graphical user interface.

The perpetual calendar is a very useful gadget. However, in contemporary times, the function of the perpetual calendar is not limited to the function of checking the time and checking the date. To this end, this system has added a more humane skin-changing function and the function of setting an alarm clock. Let the small perpetual calendar fully take over the time!

3 Outline Design

3.1 Interclass Composition Framework

In order to achieve code reuse, reduce the coupling of each module of the source program and facilitate the modification of the source code, each class is designed hierarchically from top to bottom. Using the design method of object combination, let the upper class combine the objects of the lower class, and lower the function as much as possible.

The combination relationship between each class is shown in the figure:

insert image description here

Figure 3-1 Composition relationship between classes

3.2 Schematic layout structure

The main frame of the perpetual calendar is in a NiceFrame, which is inherited from JFrame. Contains three modules: NiceMenubar, NicePanel, and Panel_Left.

NiceMenuba includes three menus: Start, Function, and Help; when the user clicks on the menu item, the corresponding part will give feedback and display on the panel.

NIceClock is placed on the top of Panel_Left, and NiceLabels is placed on the bottom; NiceLabels contains three labels, which display content by listening to the click event of the calendar.

NicePanel uses BorderLayout and is divided into three parts: Panel_North, Panel_Center and Panel_South; Panel_Center is responsible for obtaining the calculated calendar format by calling NiceBase and displaying it on the panel.

The window layout of each module is shown in the figure:

insert image description here

Figure 3-2 Layout schematic diagram

3.3 Overview of each class

insert image description here

Figure 3-3 Program UML diagram

The NiceCalendar class includes the entry of the program and the basic settings of the window, such as window size, icon, name, etc.

public class NiceCalendar{
    
    
NiceFrame NF; 
} 

The NiceFrame class, inherited from the JFrame class, is the main frame of the program responsible for the overall layout of the window.

public class NiceFrame extends JFrame{
    
    
NiceClock NC; 
  NiceMenubar NM;  
  JPanel Panel_Left;
}

The NiceClock class, which inherits from JPanel, is actually a panel. By overloading the paintComponent method, the clock is drawn on the panel by using Graphics2D.

class NiceClock extends JPanel{
    
    
ImageIcon I; 
NiceClock(ImageIcon I){
    
    }
public void paintComponent(GraphicsG){
    
    }  
}

The NiceMenuBar class inherits JMenuBar; combines NiceClock to realize the skinning function of the clock; implements the ActionListener interface to monitor the events of the menu items. The changeSkin method defined globally changes the background color.

public class NiceMenubar extends JMenuBar implements ActionListener{
    
    
  NicePanel NP;
  NiceClock NC;
NiceMenubar(NiceClock NC){
    
    }
public void actionPerformed(ActionEvent e){
    
    }
public void changeSkin(Color C){
    
    }
}

The NiceSkip class inherits JFrame and references NicePanel. Its main function is to call the refresh method of NicePanel to refresh the calendar after the Skip button is pressed.

public class NiceSkip extends JFrame implements ActionListener{
    
    
   NicePanel NP;
void Skip(NicePanel NP){
    
    }
public void actionPerformed(ActionEvent e){
    
    }
}

The NicePanel class, which combines NiceBase and NiceLabels, is responsible for drawing and refreshing the calendar, and displaying dates, festivals, and divination on the labels.

pJAublic class NicePanel extends JPanel implements ActionListener {
    
    
  NiceBase NB;
  NiceLabels NL;
void refresh(){
    
    }
public void actionPerformed(ActionEvent e) {
    
    }
}

The NiceBase class provides calendar calculation methods, receives the specified year and month, and returns an array of calendars for the current month.

public class NiceBase{
    
    
  //String day[];
  pricate int year;
  private int month;
public void setYear(int year){
    
    } 
public int getYear(){
    
    }
public void setMonth(int month){
    
    }
public int getMonth(){
    
    } 
public String[] getCalendar(){
    
    }
}

The NiceLabels class contains three labels, which are used to display festivals, divination, and alarm clocks.

public class NiceLabels extends JPanel{
    
     
Color C;
Random R;
String getTips(){
    
    }
void getRemind(int num){
    
    }
}

The NiceAlarm class, inherited from the JFramen class, is a pop-up window that receives the time input by the TextField and calls the NiceTimer class for timing.

public class NiceAlarm extends JFrame implements ActionListener{
    
    
NiceLabels NL;
}

The NiceTimer class receives the time and counts down according to the current time of the system.

Public class NiceTimer{
    
    
  NiceLabels NL; 
  int goalHour;
  int goalMinute;
public void run() {
    
    }
}

According to the requirements analysis, it can be concluded which functions and classes are needed. Define these classes, build the combination relationship between classes, and lay the foundation for the detailed design later. Each class in the system is a whole, using the combination method, when you need to use a certain label or button, you only need to call it, reducing the coupling of the code.

When using Java's Calendar class to obtain the current date, conversion is required. Because the first day of the week abroad is Sunday, but the first day of the week in China is Monday, which is a cultural difference. In order to avoid the difference, you need to set Calendar.get(Calendar.DAY_OF_WEEK)-1; and there is also the problem of time difference: use System.currentTimeMillis(); to get the system time obtained after parsing and the time obtained is inconsistent with the time in our country. This is because the time zone in which our country is located is the East Eighth District, so it is necessary to add eight time zones, which should be taken into account when converting.

4 operating environment

Java Development Kit 8

Windows 10

Intel® Core™ i5-10300H

2.50GHz CPU main frequency

8GB RAM

256GB SSD

5 Development tools and editing languages

IntelliJ IDEA 2022.1.3

Java

6 Detailed design

6.1 NiceCaelendar class

insert image description here

Figure 6-1 NiceClendar UML diagram

Set the window properties and provide the entry method of the program.

public class NiceCalendar{
    
                    
  public static void main(String[] args){
    
     //main方法 //程序入口
    NiceFrame NF = new NiceFrame();    //Window//组合
    NF.setBounds(200,200,1200,600);  //设置窗口大小 //1200X600
    Image image =                  // 将图片转换为Image对象        Toolkit.getDefaultToolkit().createImage("logo.jpg"); 
    NF.setIconImage(image);       //设置窗口图标
    NF.setTitle("Nice Calendar");      //title //窗口标题
    NF.setVisible(true); //let the window visible //窗口可见
}; // main结束
} // NiceCalendar类的结束

6.2 NiceFrame class

insert image description here

Figure 6-2 NiceFrame UML diagram

The window of JFrame type divides the window into four parts: menu, upper left, lower left, and right. NiceMenuBar is placed in the menu; NiceClock is placed on the upper left; NiceLabels is placed on the lower left; NicePanel is placed on the right.

NiceClock NC = new NiceClock(new ImageIcon("WHITE.jpg")); // 背景
NiceMenubar NM = new NiceMenubar(NC);     // 组合NiceMenu
JPanel Panel_Left = new JPanel(new GridLayout(2, 1));   // 设置布局
/*set layout //设置布局 将面板分成上下两等*/
public NiceFrame(){
    
      // 构造器
setVisible(true);                // 可见
setDefaultCloseOperation(DISPOSE_ON_CLOSE);      // 处理
Panel_Left.add(NC);              // 添加NiceClock
Panel_Left.add(NM.NP.NL);          // 添加NiceLabels
setLayout(new GridLayout(1, 2));           // 设置布局
  setJMenuBar(NM);                  // 添加菜单栏
add(Panel_Left);             // 添加Panel_Left
add(NM.NP);            // 添加NicePanel
 NM.NP.refresh();                  // 显示默认日历
} // 构造函数结束

insert image description here

Figure 6-3 NiceClock UML diagram

6.3 NiceClock class

The NiceClock class inherits the JPanel class and draws the dial on the panel by overriding the printComponent method of the parent class. The drawing process includes: turn on anti-aliasing, put in a background image, calculate the radius of the dial, draw numbers, draw scales, draw hour hands, and draw minute hands.

public void paintComponent(Graphics G){
    
     //draw components
    Graphics2D G2D = (Graphics2D)G;
    G2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);     //抗锯齿 使指针显示逼真
G2D.setColor(Color.RED); //前景颜色
    G2D.drawImage(I.getImage(),0,0,getWidth(),getHeight(),
I.getImageObserver()); //set background
int x_Width = this.getWidth() / 2; //get the width of panel
    int y_Width = this.getHeight() / 2; //get the height of panel
    int radius = (int) (Math.min(this.getWidth(), this.getHeight()) * 0.8 * 0.5); //calculate the radius of clock
    for(int i = 0; i < 12; i++){
    
     
      double angle = Math.PI / 180 * i * (360 / 12); 
      int x = (x_Width - 4) + (int)((radius - 12) * Math.cos(angle)); 
      int y = (y_Width + 4) + (int)((radius - 12) * Math.sin(angle)); 
      int j = i + 3;
      if (j > 12) 
        j = j - 12; 
      G2D.drawString(Integer.toString(j), x, y); //add numbers to clock       
    }
       AffineTransform old = G2D.getTransform();    
/*transform 2D coordinates to another*/
    for (int i = 0; i < 60; i++){
    
     
       int w = i % 5 == 0 ? 6 : 3;  //判断刻度的大小
       G2D.fillRect(x_Width - 2, 28, w, 3);      //绘制刻度
       G2D.rotate(Math.toRadians(6), x_Width, y_Width);
       } // add marks to clock
    G2D.setTransform(old);
    Calendar C = Calendar.getInstance();
    int hour = C.get(Calendar.HOUR_OF_DAY);
    int minute = C.get(Calendar.MINUTE);
    int second = C.get(Calendar.SECOND);

double hour_angle = (hour - 12 + minute / 60d) * 360d / 12d;

G2D.rotate(Math.toRadians(hour_angle), x_Width, y_Width);

int x_hour_array[] = {
    
     x_Width, x_Width + 9, x_Width, x_Width - 9 };

 int y_hour_array[] = {
    
     65, y_Width, y_Width + 10, y_Width };

 G2D.drawPolygon(x_hour_array, y_hour_array, x_hour_array.length);//绘制时针

G2D.setTransform(old);
   

double minute_angle = (minute + second / 60d) * 360d / 60d;

 G2D.rotate(Math.toRadians(minute_angle), x_Width, y_Width);

 int x_minute_array[] = {
    
     x_Width, x_Width + 6, x_Width, x_Width - 6 };//分针长度

int y_minute_array[] = {
    
     45, y_Width, y_Width + 12, y_Width };     

 G2D.drawPolygon(x_minute_array, y_minute_array, x_minute_array.length);

//绘制分针

 G2D.setTransform(old);

 }

 NiceClock(ImageIcon I){
    
    

    this.I = I;      //接收背景图片

  }

6.4 NiceMenubar class

insert image description here

Figure 6-4 NiceMenubar UML diagram

The NiceMenubar class is responsible for controlling all the functions of the perpetual calendar. Play a key role in linking the past and the future. The changeSkin method completes the skinning function by setting the background color of each button and label. Among them, the 42 buttons in the calendar are set by for loop traversal.

public void changeSkin(Color C){
    
        // 设置各种背景
    NP.NL.setBackground(C);
    NP.Button_Current.setBackground(C);
    NP.Button_Current.setBackground(C);
    NP.Button_lastYear.setBackground(C);
    NP.Button_nextYear.setBackground(C);
    NP.Button_lastMonth.setBackground(C);
    NP.Button_nextMonth.setBackground(C);
    NP.Panel_South.setBackground(C);
    NP.Panel_North.setBackground(C);
    NP.Panel_Center.setBackground(C); 
    NP.Label_Year.setBackground(C);
    NP.Label_Month.setBackground(C);
    NP.Label_Calendar.setBackground(C); 
    for(int i = 0; i < 42; i ++){
    
    
      NP.Button_Day[i].setBackground(C);
    }

  } // 换肤结束

} // NiceMenubar类结束

6.5 NicePanel class

insert image description here

Figure 6-5 NicePanel UML Diagram

NicePanel class, use the for loop to add buttons to the panel and set the button color and font. The refresh method is used to retrieve the calendar and display it again.

NicePanel(){
    
    
    setLayout(new BorderLayout());       // 边界布局
    Label_Calendar.setFont(new Font("Arove", 1, 30)); 
    Label_Calendar.setForeground(Color.RED);                          
    Panel_Center.setLayout(new GridLayout(7, 7));   // 布局:7X7网格
    for(int i = 0; i < 7; i++){
    
            // 将week[]添加到面板
      Label_Week[i] = new JLabel(Week[i], JLabel.CENTER);               
      Label_Week[i].setFont(new Font("Arvo", 1, 20));
      Label_Week[i].setForeground(Color.GREEN);
      Label_Week[i].setBackground(NL.C);
      Panel_Center.add(Label_Week[i]);
    }                       
    for(int i = 0; i < 42; i++){
    
           //add day[]添加到面板
      Button_Day[i] = new JButton("None");
      Button_Day[i].setBorder(BorderFactory.createLineBorder(Color.WHITE));
      Panel_Center.add(Button_Day[i]);                    
    } 
}

void refresh(){
    
    
    String day[] = NB.getCalendar();
    String month;
    for(int i = 0; i<42; i++){
    
                            
      Button_Day[i].setForeground(Color.CYAN);
      Button_Day[i].setFont(new Font("Arove", 1, 22));
      Button_Day[i].setText(day[i]); 
    }
    switch(NB.getMonth()){
    
    
      case 1:month = " 一月 ";break;
      case 2:month = " 二月 ";break;
      case 3:month = " 三月 ";break;
      case 4:month = " 四月 ";break;
      case 5:month = " 五月 ";break;
      case 6:month = " 六月 ";break;
      case 7:month = " 七月 ";break;
      case 8:month = " 八月 ";break;
      case 9:month = " 九月";break;
      case 10:month = " 十月 ";break;
      case 11:month = " 十一月 ";break;
      case 12:month = " 十二月 ";break;
      default:month = " NULL ";
    }
    Label_Year.setText(" "+ NB.getYear() +" ");
    Label_Month.setText(month);
  }

6.6 NiceBase class

insert image description here

Figure 6-6 NiceBase UML diagram

NiceBase class, including the method of setting the year and month, the method of getting the year and month, and the method of getting the number of the calendar button.

public void setYear(int year){
    
          //设置年份
    if(year < 2119 && year > 1919)           
    this.year = year;                       
 }                          
 public int getYear(){
    
               //返回年份
    return year;                        
 }          
 
 public void setMonth(int month){
    
          //设置月份
    if(month < 0)       
    this.month = month + 12;
    else if(month > 12)   
    this.month = month -12; 
    else
    this.month = month;                  
 }                               
 public int getMonth(){
    
              //返回月份
    return month;
  }                               

  public String[] getCalendar(){
    
           //绘制日历
    String a[] = new String[42];
    Calendar C = Calendar.getInstance();
    C.set(year, month - 1, 1);        //月份以0为基数
    int D = C.get(Calendar.DAY_OF_WEEK)-1;
    
    int day = 0;
    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
      day = 31; // 1 3 5 7 8 10 12他们每月有31天
      
    else if(month == 4||month == 6||month == 9||month == 11)
      day = 30; // 4 6 9 11他们一个月有30天
      
    else if(month == 2){
    
    
      if(((year % 4 == 0)&&(year % 100!= 0))||(year % 400 == 0))
        day = 29; // 有时29,否则28
      else
        day = 28; 
    } 
    for(int i = D, n = 1; i < D + day; i++){
    
    
      a[i] = String.valueOf(n);
      n++;
    }
    return a;
  }
}

6.7 NiceAlarm class

insert image description here

Figure 6-7 NiceAlarm UML diagram

The NiceAlarm class, when the set button is pressed, goes to the NiceTImer class to execute.

public void actionPerformed(ActionEvent e){
    
    
    
    if(e.getSource() == Textfield_H){
    
    
      NL.Label_Alarm.setText("Alarm: "+ 
      Textfield_H.getText() +":"+ Textfield_M.getText());
      
    }
    if(e.getSource() == Textfield_M){
    
    
      NL.Label_Alarm.setText("Alarm: "+ 
      Textfield_H.getText() +":"+ Textfield_M.getText());
    }
    if(e.getSource() == Button_Set){
    
    
      
      this.dispose();
      new NiceTimer(Integer.valueOf(Textfield_H.getText()),
      Integer.valueOf(Textfield_M.getText()), NL).run();
      
    }

  }

6.8 NiceTimer class

insert image description here

Figure 6-8 NiceTimer UML diagram

NiceTimer class, the run method gets the current time once per second, and calculates the difference with the target time and displays it to the terminal.

public void run() {
    
    
    int currentSecond;
    int currentMinute;
    int currentHour;
    
    do{
    
    
      long currentTime = System.currentTimeMillis();  // 获取当前时间

      currentTime = currentTime / 1000;
      currentSecond = (int) (currentTime % 60);     // 获得第二
      currentTime = currentTime / 60;
      currentMinute = (int) (currentTime % 60);     // 获取分钟
      currentTime = currentTime / 60;   
      currentHour = (int) (currentTime % 24);      // 获取小时数
      
      if (goalMinute-currentMinute > 0)
      System.out.println("闹钟: "+ (goalHour-currentHour) +" : "+
      (goalMinute-currentMinute-1) +" : "+ (59-currentSecond));
      
      try {
    
    
        Thread.sleep(1000);        // 系统暂停一秒钟
      }
      catch (InterruptedException e){
    
    
        e.toString();
      } 
    }while (goalHour*100+goalMinute > currentHour*100+currentMinute);
    
    NL.Label_Alarm.setText("闹钟:时间到!"); // 时间到

  }

}

6.9 NiceLabels class

insert image description here

Figure 6-9 NiceLabels UML diagram

NiceLabels class, the main function is to set the label content, the getTips() method and getRemind() method can return the divination and festival of the corresponding date.

String getTips(){
    
    
   int i = R.nextInt(10);
   String S[] = new String[10];
   S[0] = "小贴士:既不好也不坏";
   S[1] = "小贴士:不喝酒/不旅行/不参加葬礼";
   S[2] = "小贴士:参观/贸易/理发/旅行";
   S[3] = "小贴士:禁止砍伐/结婚/洗澡";
   S[4] = "小贴士:不要祈祷/建造/种植";
   S[5] = "小贴士:无所事事/倒霉的一天";
   S[6] = "小贴士:祈祷/结婚/洗澡/旅行";
   S[7] = "小贴士:不结婚/不游泳/装饰";
   S[8] = "小贴士:禁止建造/禁止交易/砍伐树木";
   S[9] = "小贴士:一切顺利";

   return S[i];
}
void getRemind(int num){
    
    
   switch(num){
    
    
     case 11: Label_Remind.setText("提醒:1月1日元旦");break;
     case 214: Label_Remind.setText("提醒:2月14日情人节");break;
     case 38: Label_Remind.setText("提醒:3月8日妇女节");break;
     case 41: Label_Remind.setText("提醒:4月1日愚人节");break;
     case 422: Label_Remind.setText("提醒:4月22日地球日");break;
     case 51: Label_Remind.setText("提醒:五一劳动节");break;
          case 54: Label_Remind.setText("提醒:五四青年节");break;
          case 57: Label_Remind.setText("提醒:五七回华诞");break;
     case 61: Label_Remind.setText("提醒:6月1日儿童节");break;
     case 71: Label_Remind.setText("提醒:七一建党纪念日");break;
          case 81: Label_Remind.setText("提醒:8月1日建军节");break;
          case 96: Label_Remind.setText("提醒:9月6日我的生日");break;
     case 910: Label_Remind.setText("提醒:9月10日教师节");break;
     case 101: Label_Remind.setText("提醒:10月1日国庆节");break;
     case 1128: Label_Remind.setText("提醒:11月28日感恩节");break;
     case 1224: Label_Remind.setText("提醒:12月24日平安夜");break;
     case 1225: Label_Remind.setText("提醒:12月25日圣诞节");break;
     default: Label_Remind.setText("提醒:NULL");
   }

  }

}

7 Debug Analysis

7.1 0:-1:59问题

In the timer function, the countdown time is displayed on the terminal terminal, but when the timing ends, it does not display 0:0:0, but 0:-1:59. Later, I found the reason and found that it was because:

The timing function uses a do-while loop, that is, the timing number is output first, and then it is judged whether the timing is over. This will cause each timing to output an extra second, which is the next second of 0:0:0, 0:-1:59.

The solution is to avoid the output of the last round of extra loops, and limit it with a judgment statement: if(goalMinute-currentMinute >= 0){}

insert image description here

Figure 6-1 0:-1:59Question

insert image description here

Figure 6-2 The effect after repair

7.2 The color problem of the menu bar

In the skinning function, the realization principle of the function is to change the background color. For labels and buttons, you can use the setBackground() method, but not for menu bars. Although the color of the menu bar does not affect the skin effect very much, if it can be changed, the display effect will be better. So I searched for a solution on the Internet. Some said that the void paintComponent (Graphics G) method must be overloaded, and some said that setBackground() could be used, but it was not suitable. Finally, a netizen mentioned this method, which is particularly effective getComponent().setBackground(), so this problem was solved smoothly.

7.3 Time difference problem

In the timer function, in order to synchronize the time, you need to call the System.currentTimeMillis() method to get the current milliseconds, and then parse it, as follows:

currentTime = currentTime / 1000;

currentSecond = (int) (currentTime % 60);      // 获得第二

currentTime = currentTime / 60;

currentMinute = (int) (currentTime % 60);        // 获取分钟

currentTime = currentTime / 60;   

currentHour = (int) (currentTime % 24);       // 获取小时数

However, there is a problem with the number of hours obtained from this. After several rounds of debugging, it is found that there is always a difference of 8 hours from the current time. Later, I heard and thought, it should be because Beijing time is in the East Eighth District, and the obtained time is standard time. The solution is to subtract 8 from the time entered by the user and convert it to standard time before using it.

7.4 Function Supplement

If you have time, you should add a function that allows users to customize date reminders, so that users can add custom items such as birthdays and meetings, and the human-computer interaction is more free.

There is also a login function, with a database, which can save user-defined reminders and alarm clock data in real time.

8 Test results

8.1 Jump function

Under the Function menu, there are alarm clock, jump, previous year, next year, previous month, next month and other functions. Test the jump function under the Function menu to jump to October 1, 2023.

insert image description here

Figure 8-1 Before jumping, window input

insert image description here

Figure 8-2 After the jump, the date changes

8.2 Skinning function

Test the skin function under the menu.

There are four skin options: quiet white, soft yellow, pure black, and dusk dark. Choose dusk dark and pure black for testing.

insert image description here

Figure 8-3 Dark colors at dusk

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-SdU5BqAf-1688105247808)(images/image-20230630140039785.png)]

Figure 8-4 Pure black

8.3 Timing function

Test the alarm clock function under the function menu. The current time is 20:53, set an alarm clock and remind at 20:53.

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-XgtQTU0z-1688105247809)(images/image-20230630140059539.png)]

Figure 8-5 Before timing, window input

insert image description here

Figure 8-6 When running, the terminal displays a countdown

insert image description here

Figure 8-7 Time is up, display time is up!

8.4 Show About

The help menu provides some information about the developer. Among them, the readme file shows the instructions for using the software, and the personal information of the developer is displayed.

Test the About prompt under the Help menu

insert image description here

Figure 8-8 About developers

9 Summary and Outlook

Through this course design, we have deepened our understanding of the theory, methods and basic knowledge of object-oriented programming. At the same time, we have also mastered the basic methods of using Java language for object-oriented design, and improved the ability to use object-oriented knowledge to analyze and solve practical problems. It is further recognized that in the Java language, internal classes cannot access variables in external classes arbitrarily, unless they are final. In addition, in the process of writing programs, the use of the java compiler is also essential. It can help us quickly and intuitively know many classes and corresponding methods, such as the getInstance method in Canlender. In the future, we will use our spare time to continue learning the Java language, and strive to master it better and achieve the level of ease of use. This course design has given me a deeper understanding of this course. "JAVA Programming" is not a simple computer language, it can be extended to a wider and wider field.
Resource link: Java-based perpetual calendar (course design)

Guess you like

Origin blog.csdn.net/weixin_55756734/article/details/131475591