阴历及节日程序 beta1.docx

上传人:b****6 文档编号:15450413 上传时间:2023-07-04 格式:DOCX 页数:19 大小:24.20KB
下载 相关 举报
阴历及节日程序 beta1.docx_第1页
第1页 / 共19页
阴历及节日程序 beta1.docx_第2页
第2页 / 共19页
阴历及节日程序 beta1.docx_第3页
第3页 / 共19页
阴历及节日程序 beta1.docx_第4页
第4页 / 共19页
阴历及节日程序 beta1.docx_第5页
第5页 / 共19页
阴历及节日程序 beta1.docx_第6页
第6页 / 共19页
阴历及节日程序 beta1.docx_第7页
第7页 / 共19页
阴历及节日程序 beta1.docx_第8页
第8页 / 共19页
阴历及节日程序 beta1.docx_第9页
第9页 / 共19页
阴历及节日程序 beta1.docx_第10页
第10页 / 共19页
阴历及节日程序 beta1.docx_第11页
第11页 / 共19页
阴历及节日程序 beta1.docx_第12页
第12页 / 共19页
阴历及节日程序 beta1.docx_第13页
第13页 / 共19页
阴历及节日程序 beta1.docx_第14页
第14页 / 共19页
阴历及节日程序 beta1.docx_第15页
第15页 / 共19页
阴历及节日程序 beta1.docx_第16页
第16页 / 共19页
阴历及节日程序 beta1.docx_第17页
第17页 / 共19页
阴历及节日程序 beta1.docx_第18页
第18页 / 共19页
阴历及节日程序 beta1.docx_第19页
第19页 / 共19页
亲,该文档总共19页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

阴历及节日程序 beta1.docx

《阴历及节日程序 beta1.docx》由会员分享,可在线阅读,更多相关《阴历及节日程序 beta1.docx(19页珍藏版)》请在冰点文库上搜索。

阴历及节日程序 beta1.docx

阴历及节日程序beta1

/************************************

 阴历及节日程序2008beta1

 免费软件(FreeSoftware)你可以无限传播与反编译

 该日历有三种外观样式,有从1900年至2049年间的所有阴历

 个人爱好开发 作者:

朱春Email:

npuxbd@

 Copyright@2008-AllRightsReserved

 FileName:

Simple_Calendar

 **********************************/

importjava.text.*;

importjava.awt.*;

importjavax.swing.*;

importjava.awt.event.*;

importjavax.swing.border.*;

importjava.util.*;

importjavax.swing.*;

publicclassSimple_CalendarextendsJFrameimplementsActionListener{

 

 publicstaticvoidmain(String[]args){

  

  SwingConsole.run(newSimple_Calendar(),525,525);

 }

 

 publicSimple_Calendar(){

  setTitle("阴历及节日软件2008beta1");

  setIconImage(this.getToolkit().createImage("title.gif"));

  setResizable(false);

  calendar=Calendar.getInstance();

  today=calendar.get(Calendar.DAY_OF_MONTH);

  panel_Header=initializtion_Header();

  panel_Week=initializtion_Week();

  panel_Calendar=initializtion_Calendar();

  setLayout(null);

  setBounds(185,125,0,0);

  add(panel_Header);panel_Calendar.setBounds(0,0 ,525,45);

  add(panel_Week);    panel_Week.setBounds(0,45,525,35);

    add(panel_Calendar);panel_Calendar.setBounds(0,80,525,415);

    initializtion_Data(calendar);

    

  

  

 }

   private JPanelinitializtion_Header(){//显示表头的panel

      

    JPanelpanel=newJPanel();

    year_box =new JComboBox();

    month_box=newJComboBox();

    cross=newJRadioButton("c",false);cross.addActionListener(newLookAndFeel_Listener());

    system=newJRadioButton("s",false);system.addActionListener(newLookAndFeel_Listener());

    motif=newJRadioButton("m",false);motif.addActionListener(newLookAndFeel_Listener());

    feel_group=newButtonGroup();

    show_help=newJButton("说明");

    

    show_help.addActionListener(newStatement_Listener());

    

    feel_group.add(cross);feel_group.add(system);feel_group.add(motif);

    panel.setBorder(newEtchedBorder(5,Color.red,Color.BLUE));

    JLabelyear_l=newJLabel("请您选择年份:

",JLabel.RIGHT);

    JLabelmonth_l=newJLabel("月份:

",JLabel.RIGHT);

    panel.setLayout(null);

    panel.setSize(525,45);

 

 

    for(inti=1900;i<2050;i++)

      year_box.addItem(""+i);

    for(intj=1;j<=12;j++)

      month_box.addItem(""+j);

   

    year_box.setSelectedIndex(calendar.get(Calendar.YEAR)-1900);

    month_box.setSelectedIndex(calendar.get(Calendar.MONTH));

    panel.add(year_l);     year_l.setBounds(0,10,95,25);

    panel.add(year_box); year_box.setBounds(100,10,65,25);

    panel.add(month_l);   month_l.setBounds(160,10,45,25);

    panel.add(month_box);month_box.setBounds(210,10,45,25);

    JLabellook_feel=newJLabel("外观:

",JLabel.RIGHT);

    panel.add(look_feel);look_feel.setBounds(290-38,10,38,25);

    panel.add(cross);      cross.setBounds(290,10,38,25);

    panel.add(system);    system.setBounds(325,10,32,25);

    panel.add(motif);      motif.setBounds(355,10,38,25);

    panel.add(show_help); show_help.setBounds(400,10,65,25);

    show_help.setBorder(newEmptyBorder(0,0,0,0));

    show_help.setBackground(Color.getHSBColor(23,21,10));

    year_box.addActionListener(this);

    month_box.addActionListener(this);

    returnpanel;

   }

   privateJPanelinitializtion_Week(){//显示星期的panel

  JPanelpanel=newJPanel();

  

  panel.setLayout(newGridLayout(1,7));

  

  StringcolumnNames[]={"星期日","星期一","星期二","星期三",

                                 "星期四","星期五","星期六"};

       JLabellabel=null;

       for(inti=0;i<7;i++){

        label=newJLabel(columnNames[i],JLabel.CENTER);

        if(i==0||i==6)

         label.setForeground(Color.RED);

        label.setBorder(newLineBorder(Color.BLUE));

        panel.add(label);

       }

       returnpanel;

 }

   privateJPanelinitializtion_Calendar(){//显示日期的panel

       JPanelpanel=newJPanel();

     

       panel.setLayout(newGridLayout(6,7));

       for(inti=0;i<6;i++){

        for(intj=0;j<7;j++){

        label=newJLabel("",JLabel.CENTER);

        

        datas[i][j]=label;

        label.setBorder(newLineBorder(Color.BLUE));

        if(j==0||j==6)

          label.setForeground(Color.RED); 

        datas[i][j].addMouseListener(newList_MouseListener());

        panel.add(label);

       }

    }

    returnpanel;

   }

   

   public voidclear_Data(){//清空内容的

    for(inti=0;i<6;i++)

    for(intj=0;j<7;j++){

     datas[i][j].setText("");

     if(j==0||j==6)

       datas[i][j].setForeground(Color.RED);

     else

       datas[i][j].setForeground(null);

    }

        

   }

   public voidinitializtion_Data(Calendarcalendar){//初始化函数

  ////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////

   /*节日和纪念日

格式:

起始年(yyyy)+月(mm)+日(dd)

 

0000表示起始年不明*/

HashMap sFestival=new HashMap();

//String[]sFestival_={

sFestival.put("0101"," 元旦");

sFestival.put("0214","情人节");

sFestival.put("0308","妇女节");

sFestival.put("0312","植树节");

sFestival.put("0401","愚人节");

sFestival.put("0501","劳动节");

sFestival.put("0504","青年节");

sFestival.put("0601","儿童节");

sFestival.put("0701","建党节");

sFestival.put("0801","建军节");

sFestival.put("0910","教师节");

sFestival.put("1001","国庆节");

sFestival.put("1031","万圣节");

sFestival.put("1112","孙中山诞辰");

sFestival.put("1225","圣诞节");

sFestival.put("1226","毛泽东诞辰");

//};

//某月第几个星期几

//起始年(4位)+月(2位)+第几个(1位)+星期几(1位)

HashMap wFestival=new HashMap();

//String[]wFestival={

wFestival.put("0520","母亲节");

wFestival.put("0630","父亲节");

wFestival.put("1144","感恩节");

//};

//农历99表示月最后一天

HashMap lFestival=new HashMap();

//String[]lFestival={

lFestival.put("0101","春节");

lFestival.put("0102","大年初二");

lFestival.put("0103","大年初三");

lFestival.put("0115","元宵节");

lFestival.put("0505","端午节");

lFestival.put("0707","七夕");

lFestival.put("0815","中秋节");

lFestival.put("0909","重阳节");

lFestival.put("1208","腊八节");

lFestival.put("1299","除夕");

//};

   

/////////////////////////////////////////////////////////////

   

  //////////////////////////////////////////////////// 

     this.calendar=calendar;

     today=calendar.get(Calendar.DAY_OF_MONTH);

     intmonth=calendar.get(Calendar.MONTH);

     intweekindexDay;

  intweekindexMonth;

  

  calendar.set(Calendar.DATE,1);

  

  while(calendar.get(Calendar.MONTH)==month)

  {  weekindexMonth=calendar.get(Calendar.WEEK_OF_MONTH)-1;

     weekindexDay=calendar.get(Calendar.DAY_OF_WEEK)-1;

     intday=calendar.get(Calendar.DAY_OF_MONTH);

     ///////////////////////////////////////////////

     Stringtoday_,month_;

     today_=day<10?

 "0"+day:

""+day;

     month_=month<10?

 "0"+(month+1):

""+(month+1);

     Lunarlunar=newLunar(calendar);

     Stringlunar_=lunar.toString();

     ///////////////////////////////////////////

     if(null!

=sFestival.get(month_+today_))

          lunar_=""+sFestival.get(month_+today_);

     ///////

     StringwFestival_=month_+(weekindexMonth)+(weekindexDay);

     

     if(null!

=wFestival.get(wFestival_)){

      lunar_=""+wFestival.get(wFestival_);

      System.out.println(wFestival_);

     }

         

     

     

     

     if(null!

=lFestival.get(lunar.numeric_md()))

         lunar_=""+lFestival.get(lunar.numeric_md());

     

     

         

     //计算除夕

     Calendartemp_calendar=Calendar.getInstance();

     temp_calendar.set(calendar.get(Calendar.YEAR),month,day+1);

     

     //temp_calendar.add(Calendar.DAY_OF_MONTH,1);

     Lunartemp_lunar=newLunar(temp_calendar);

     Stringtemp_str=temp_lunar.numeric_md();

      if(temp_str.equals("0101"))

         lunar_=""+lFestival.get("1299");

     ///计算除夕结束

     //////////////////////////////////////////

     Stringday_str;

     if(day<10)day_str="

"+today_;

     else      day_str="

"+today_;

     

     day_str+="
"+lunar_;

   

     if(day==today)

        datas[weekindexMonth][weekindexDay].setForeground(Color.GREEN);

     datas[weekindexMonth][weekindexDay].setText(day_str);

     calendar.add(Calendar.DATE,1);

  } 

    

    

    

 /////////////////////////////////////////////////   

   }

   public voidactionPerformed(ActionEvente){//日期和年份的选择更新

    intyear=Integer.parseInt(year_box.getSelectedItem().toString());

    intmonth=Integer.parseInt(month_box.getSelectedItem().toString())-1;

    calendar.set(year,month,today);

    clear_Data();

       initializtion_Data(calendar);

   }

   classLookAndFeel_ListenerimplementsActionListener{//选择外观的样式

 publicvoidactionPerformed(ActionEventev){

  JRadioButtono=(JRadioButton)ev.getSource();

  Stringstr=o.getText();

  if("c"==str){

   try{UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());

           }catch(Exceptione){e.printStackTrace();}

  }elseif("s"==str){

   try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

            }catch(Exceptione){e.printStackTrace();}

  }elseif("m"==str){

   try{UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");}

           catch(Exceptione){e.printStackTrace();}

  }

  SwingUtilities.updateComponentTreeUI(Simple_Calendar.this);

  }

 

   }

   classStatement_ListenerimplementsActionListener{//显示声明信息

    JDialogdialog=null;

    publicvoidactionPerformed(ActionEventev){

      Stringstatment="阴历及节日程序2008beta1";

      statment+="
免费软件(FreeSoftware)你可以无限

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2