用java程序写日历_我用java写的日历

public class Calendar {  /**   * 直接的可以查看效果   * @param args   */  public static void main(String[] args) {      int year=input.nextInt();//年   int month=input.nextInt();//月   int yearday=0;//年总天数   //计算从1900年到今年之间的时间   for (int i = 1900; i < year; i++) {    //计算闰年的条件    if(i%4==0&&i%100!=0||i%400==0){     yearday=yearday+366;    }else{     yearday=yearday+365;    }   }   int day=0;//一个月的天数   int monthday=0;//今年一月到本月的天数   int sumday=0;//距离1900年的总天数   //计算今年一月到本月的天数   for (int i = 1; i <=month; i++) {    switch(i){    case 1:    case 3:    case 5:    case 7:    case 8:    case 10:    case 12:     day=31;     break;    case 2:     if(year%4==0&&year%100!=0||year%400==0){      day=29;      break;     }else{      day=28;      break;     }     default:      day=30;      break;     }    if(i

ublic class JCalendar extends JPanel{ //动态表示年月日 private int year=0; private int month=0; private int day=0; private int first = 0; //用于标志日历面板是否显示 private static boolean isShow = false; //主面板 private JPanel Main = new JPanel(); //日面板 private JPanel jPanelDay = new JPanel(); //月面板 private JPanel jPanelMonth = new JPanel(); //月的输入位置 private JTextField Month = new JTextField(); //减少月份 private JButton MonthDown = new JButton(); //增加月份 private JButton MonthUp = new JButton(); private JPanel jPanelButton = new JPanel(); //减少年份 private JButton YearDown = new JButton(); //增加年份 private JButton YearUp = new JButton(); //显示日期的位置 private JLabel Out = new JLabel(); public JLabel Out2 = new JLabel(); private Locale l=Locale.CHINESE; //主日历 private GregorianCalendar cal=new GregorianCalendar(l); //星期面板 private JPanel weekPanel=new JPanel(); //天按钮组 private JToggleButton[] days=new JToggleButton[42]; //天面板 private JPanel Days = new JPanel(); //标示 private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JLabel jLabel3 = new JLabel(); private JLabel jLabel4 = new JLabel(); private JLabel jLabel5 = new JLabel(); private JLabel jLabel6 = new JLabel(); private JLabel jLabel7 = new JLabel(); //当前选择的天数按钮 private JToggleButton cur=null; //月份天数数组,用来取得当月有多少天 // 1 2 3 4 5 6 7 8 9 10 11 12 private int[] mm={31,28,31,30,31,30,31,31,30,31,30,31}; //空日期构造函数 public JCalendar() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //带日期设置的构造函数 public JCalendar(int year, int month, int day) { cal.set(year, month, day); try { jbInit(); } catch (Exception e) { e.printStackTrace(); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值