Write a calendar applet in Java-code

Source: Internet
Author: User

Sdate section:

class Sdate {
public static int accountdays (int year,int month) {
Switch (month) {
         Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case:
         Case A:
return;
             Case 2:
if (isleap)
return;
else return 28;         
Default:
Return
            
}
public static Boolean isleap (int year) {
if (year%4 = = 0 && year%100!= 0)
return true;         
Else if (year%100 = = 0 && year%400 = 0)
return true;
     else
return false;
        
public static int fixday (int year,int month) {
int base_year = 1;
Int[] Base_month = {0,0,3,3,6,1,4,0,3,5,0,3,5};         
if (isleap (year)) {
base_year++
     for (int i = 3; i<=6; i++) {
Base_month[i] + = 1;
                 if (base_month[i] = = 7) {
Base_month[i] = 0;
                
}
for (int i = 9; I <= i++) {
Base_month[i] + = 1;
                 if (base_month[i] = = 7) {
Base_month[i] = 0;

}
}
Return (year+year/4+year/400-year/100-base_year+base_month[month]+1)%7;}
}

Dategrid section:

import Javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.*;
public class DateGrid extends JWindow implements ActionListener {
     //DateGrid的构造方法
     public DateGrid() {
         super();
         this.design();
     }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.