/************************************
陰歷及節(jié)日程序 2008 beta1
免費軟件(Free Software) 你可以無限傳播與反編譯
該日歷有三種外觀樣式,有從1900年至2049年間的所有陰歷
個人愛好開發(fā) 作者:朱春 Email:npuxbd@163.com
Copyright @ 2008- All Rights Reserved
FileName: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(" 陰歷及節(jié)日軟件 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(){//顯示星期的panel
JPanel 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(){//清空內(nèi)容的
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){//初始化函數(shù)
////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
/* 節(jié)日和紀念日
格式:起始年(yyyy)+月(mm)+日(dd)
0000表示起始年不明*/
HashMap<String,String> sFestival =new HashMap<String,String>();
//String []sFestival_={
sFestival.put("0101"," 元旦");
sFestival.put("0214","情人節(jié)");
sFestival.put("0308","婦女節(jié)");
sFestival.put("0312","植樹節(jié)");
sFestival.put("0401","愚人節(jié)");
sFestival.put("0501","勞動節(jié)");
sFestival.put("0504","青年節(jié)");
sFestival.put("0601","兒童節(jié)");
sFestival.put("0701","建黨節(jié)");
sFestival.put("0801","建軍節(jié)");
sFestival.put("0910","教師節(jié)");
sFestival.put("1001","國慶節(jié)");
sFestival.put("1031","萬圣節(jié)");
sFestival.put("1112","孫中山誕辰");
sFestival.put("1225","圣誕節(jié)");
sFestival.put("1226","毛澤東誕辰");
//};
//某月第幾個星期幾
//起始年(4位)+月(2位)+第幾個(1位)+星期幾(1位)
HashMap<String,String> wFestival =new HashMap<String,String>();
//String []wFestival={
wFestival.put("0520","母親節(jié)");
wFestival.put("0630","父親節(jié)");
wFestival.put("1144","感恩節(jié)");
//};
//農(nóng)歷 99表示月最后一天
HashMap<String,String> lFestival =new HashMap<String,String>();
//String []lFestival={
lFestival.put("0101","春 節(jié)");
lFestival.put("0102","大年初二");
lFestival.put("0103","大年初三");
lFestival.put("0115","元宵節(jié)");
lFestival.put("0505","端午節(jié)");
lFestival.put("0707","七 夕");
lFestival.put("0815","中秋節(jié)");
lFestival.put("0909","重陽節(jié)");
lFestival.put("1208","臘八節(jié)");
lFestival.put("1299","除 夕");
//};
/////////////////////////////////////////////////////////////
本文導(dǎo)航
- 第1頁: 首頁
- 第2頁: 比較陰歷陽歷2
- 第3頁: 比較陰歷陽歷3