1. 首页 > 电脑教程 > 比较综合的阴历和阳历的java源程序

比较综合的阴历和阳历的java源程序

/************************************阴历及节日程序 2008 beta1免费软件(Free Software) 你可以无限传播与反编译该日历有三种外观样式,有从1900年至2049年间的所有阴历个人爱好开发 作者:朱春 Email:npuxbd@163.comCopyright @ 2008- All Rights ReservedFileName:Simple_Calendar**********************************/import java.text.*;import java.awt.*;import javax.swing.*;import java.awt.event.*;import javax.swing.border.*;import java.util.*;import javax.swing.*;public class Simple_Calendar extends JFrame implements ActionListener{

public static void main(String[] args) {SwingConsole.run(new Simple_Calendar(),525,525);}

public Simple_Calendar() {setTitle(" 阴历及节日软件 2008 beta1");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 JPanel initializtion_Header(){//显示表头的panel JPanel panel = new JPanel(); year_box = new JComboBox(); month_box = new JComboBox(); cross=new JRadioButton("c",false);cross.addActionListener(new LookAndFeel_Listener()); system=new JRadioButton("s",false);system.addActionListener(new LookAndFeel_Listener()); motif=new JRadioButton("m",false);motif.addActionListener(new LookAndFeel_Listener()); feel_group= new ButtonGroup(); show_help = new JButton("说 明"); show_help.addActionListener(new Statement_Listener()); feel_group.add(cross);feel_group.add(system);feel_group.add(motif); panel.setBorder(new EtchedBorder(5,Color.red,Color.BLUE)); JLabel year_l = new JLabel("请您选择年份: ",JLabel.RIGHT); JLabel month_l = new JLabel("月份: ",JLabel.RIGHT); panel.setLayout(null); panel.setSize(525,45);

for(int i = 1900 ;i < 2050 ; i++) year_box.addItem(""+i); for(int j = 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); JLabel look_feel = new JLabel("外观:",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(new EmptyBorder(0,0,0,0)); show_help.setBackground(Color.getHSBColor(23,21,10)); year_box.addActionListener(this); month_box.addActionListener(this); return panel; } private JPanel initializtion_Week(){//显示星期的panelJPanel panel = new JPanel();panel.setLayout(new GridLayout(1,7));String columnNames[]={"星期日","星期一","星期二","星期三", "星期四","星期五","星期六"}; JLabel label =null; for(int i=0;i<7;i++){ label = new JLabel(columnNames[i],JLabel.CENTER); if(i == 0 || i == 6) label.setForeground(Color.RED); label.setBorder(new LineBorder(Color.BLUE)); panel.add(label); } return panel;} private JPanel initializtion_Calendar(){//显示日期的panel JPanel panel = new JPanel(); panel.setLayout(new GridLayout(6,7)); for( int i = 0 ; i < 6 ; i++ ){ for(int j = 0 ; j < 7 ; j++ ){ label=new JLabel("",JLabel.CENTER); datas[i][j] = label; label.setBorder(new LineBorder(Color.BLUE)); if(j==0 || j==6) label.setForeground(Color.RED); datas[i][j].addMouseListener(new List_MouseListener()); panel.add(label); } } return panel; } public void clear_Data(){//清空内容的 for(int i = 0 ; i < 6 ; i++ ) for(int j = 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 void initializtion_Data(Calendar calendar){//初始化函数 //////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /* 节日和纪念日格式:起始年(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","除 夕");//}; /////////////////////////////////////////////////////////////

声明:希维路由器教程网提供的内容,仅供网友学习交流,如有侵权请与我们联系删除,谢谢。ihuangque@qq.com
本文地址:https://www.ctrlcv.com.cn/diannao/169323481110657.html